Show friends on anime
This commit is contained in:
parent
c0e324cefd
commit
22fe164f34
@ -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
|
||||
description := anime.Summary
|
||||
|
||||
@ -70,5 +88,5 @@ func Get(ctx *aero.Context) string {
|
||||
|
||||
ctx.Data = openGraph
|
||||
|
||||
return ctx.HTML(components.Anime(anime, tracks, user, episodesReversed))
|
||||
return ctx.HTML(components.Anime(anime, friends, tracks, user, episodesReversed))
|
||||
}
|
||||
|
@ -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)
|
||||
if anime.Image.Small != ""
|
||||
.anime-image-container
|
||||
@ -35,6 +35,12 @@ component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, user *arn.User, epis
|
||||
Icon("plus")
|
||||
span Add to collection
|
||||
|
||||
if len(friends) > 0
|
||||
h3.anime-section-name Friends
|
||||
|
||||
.anime-friends
|
||||
UserGrid(friends)
|
||||
|
||||
h3.anime-section-name Ratings
|
||||
.anime-rating-categories
|
||||
.anime-rating-category(title=toString(anime.Rating.Overall))
|
||||
|
@ -92,6 +92,10 @@
|
||||
.anime-rating-categories
|
||||
vertical
|
||||
|
||||
.anime-friends
|
||||
.user-avatars
|
||||
justify-content flex-start
|
||||
|
||||
.footer
|
||||
font-size 0.8rem
|
||||
opacity 0.7
|
||||
|
@ -88,7 +88,7 @@ func dashboard(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
followingList = userList.([]*arn.User)
|
||||
followingList = arn.SortUsersLastSeen(followingList)
|
||||
arn.SortUsersLastSeen(followingList)
|
||||
|
||||
if len(followingList) > maxFollowing {
|
||||
followingList = followingList[:maxFollowing]
|
||||
|
@ -2,7 +2,6 @@ package profile
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
@ -20,10 +19,7 @@ func GetFollowers(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
followers := viewUser.Followers()
|
||||
|
||||
sort.Slice(followers, func(i, j int) bool {
|
||||
return followers[i].LastSeen > followers[j].LastSeen
|
||||
})
|
||||
arn.SortUsersLastSeen(followers)
|
||||
|
||||
return ctx.HTML(components.ProfileFollowers(followers, viewUser, utils.GetUser(ctx), ctx.URI()))
|
||||
|
||||
|
@ -2,10 +2,18 @@ component ProfileFollowers(followers []*arn.User, viewUser *arn.User, user *arn.
|
||||
ProfileHeader(viewUser, user, uri)
|
||||
|
||||
if len(followers) > 0
|
||||
.user-avatars
|
||||
each user in followers
|
||||
if user.Nick != ""
|
||||
UserGrid(followers)
|
||||
else
|
||||
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
|
||||
Avatar(user)
|
||||
else
|
||||
p.no-data.mountable= viewUser.Nick + " doesn't have a follower yet."
|
||||
else
|
||||
.mountable
|
||||
.inactive-user
|
||||
Avatar(user)
|
2
pages/profile/followers.scarlet
Normal file
2
pages/profile/followers.scarlet
Normal file
@ -0,0 +1,2 @@
|
||||
.inactive-user
|
||||
opacity 0.25
|
Loading…
Reference in New Issue
Block a user