Show friends on anime

This commit is contained in:
Eduard Urbach 2017-07-21 11:25:53 +02:00
parent c0e324cefd
commit 22fe164f34
7 changed files with 47 additions and 13 deletions

View File

@ -40,6 +40,24 @@ func Get(ctx *aero.Context) string {
} }
} }
// Friends watching
var friends []*arn.User
if user != nil {
friends = user.Follows().Users()
deleted := 0
for i := range friends {
j := i - deleted
if !friends[j].AnimeList().Contains(anime.ID) {
friends = friends[:j+copy(friends[j:], friends[j+1:])]
deleted++
}
}
arn.SortUsersLastSeen(friends)
}
// Open Graph // Open Graph
description := anime.Summary description := anime.Summary
@ -70,5 +88,5 @@ func Get(ctx *aero.Context) string {
ctx.Data = openGraph ctx.Data = openGraph
return ctx.HTML(components.Anime(anime, tracks, user, episodesReversed)) return ctx.HTML(components.Anime(anime, friends, tracks, user, episodesReversed))
} }

View File

@ -1,4 +1,4 @@
component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, user *arn.User, episodesReversed bool) component Anime(anime *arn.Anime, friends []*arn.User, tracks []*arn.SoundTrack, user *arn.User, episodesReversed bool)
.anime-header(data-id=anime.ID) .anime-header(data-id=anime.ID)
if anime.Image.Small != "" if anime.Image.Small != ""
.anime-image-container .anime-image-container
@ -35,6 +35,12 @@ component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, user *arn.User, epis
Icon("plus") Icon("plus")
span Add to collection span Add to collection
if len(friends) > 0
h3.anime-section-name Friends
.anime-friends
UserGrid(friends)
h3.anime-section-name Ratings h3.anime-section-name Ratings
.anime-rating-categories .anime-rating-categories
.anime-rating-category(title=toString(anime.Rating.Overall)) .anime-rating-category(title=toString(anime.Rating.Overall))

View File

@ -92,6 +92,10 @@
.anime-rating-categories .anime-rating-categories
vertical vertical
.anime-friends
.user-avatars
justify-content flex-start
.footer .footer
font-size 0.8rem font-size 0.8rem
opacity 0.7 opacity 0.7

View File

@ -88,7 +88,7 @@ func dashboard(ctx *aero.Context) string {
} }
followingList = userList.([]*arn.User) followingList = userList.([]*arn.User)
followingList = arn.SortUsersLastSeen(followingList) arn.SortUsersLastSeen(followingList)
if len(followingList) > maxFollowing { if len(followingList) > maxFollowing {
followingList = followingList[:maxFollowing] followingList = followingList[:maxFollowing]

View File

@ -2,7 +2,6 @@ package profile
import ( import (
"net/http" "net/http"
"sort"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
@ -20,10 +19,7 @@ func GetFollowers(ctx *aero.Context) string {
} }
followers := viewUser.Followers() followers := viewUser.Followers()
arn.SortUsersLastSeen(followers)
sort.Slice(followers, func(i, j int) bool {
return followers[i].LastSeen > followers[j].LastSeen
})
return ctx.HTML(components.ProfileFollowers(followers, viewUser, utils.GetUser(ctx), ctx.URI())) return ctx.HTML(components.ProfileFollowers(followers, viewUser, utils.GetUser(ctx), ctx.URI()))

View File

@ -2,10 +2,18 @@ component ProfileFollowers(followers []*arn.User, viewUser *arn.User, user *arn.
ProfileHeader(viewUser, user, uri) ProfileHeader(viewUser, user, uri)
if len(followers) > 0 if len(followers) > 0
.user-avatars UserGrid(followers)
each user in followers else
if user.Nick != "" p.no-data.mountable= viewUser.Nick + " doesn't have a follower yet."
component UserGrid(users []*arn.User)
.user-avatars
each user in users
if user.Nick != ""
if user.IsActive()
.mountable .mountable
Avatar(user) Avatar(user)
else else
p.no-data.mountable= viewUser.Nick + " doesn't have a follower yet." .mountable
.inactive-user
Avatar(user)

View File

@ -0,0 +1,2 @@
.inactive-user
opacity 0.25