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
|
// 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))
|
||||||
}
|
}
|
||||||
|
@ -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))
|
||||||
|
@ -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
|
||||||
|
@ -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]
|
||||||
|
@ -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()))
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
UserGrid(followers)
|
||||||
|
else
|
||||||
|
p.no-data.mountable= viewUser.Nick + " doesn't have a follower yet."
|
||||||
|
|
||||||
|
component UserGrid(users []*arn.User)
|
||||||
.user-avatars
|
.user-avatars
|
||||||
each user in followers
|
each user in users
|
||||||
if user.Nick != ""
|
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)
|
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