Show followers' anime list item
This commit is contained in:
parent
22fe164f34
commit
0d9b6330ee
@ -1,5 +1,8 @@
|
||||
component Avatar(user *arn.User)
|
||||
a.user.ajax(href="/+" + user.Nick, title=user.Nick)
|
||||
CustomAvatar(user, user.Link(), user.Nick)
|
||||
|
||||
component CustomAvatar(user *arn.User, link string, title string)
|
||||
a.user.ajax(href=link, title=title)
|
||||
AvatarNoLink(user)
|
||||
|
||||
component AvatarNoLink(user *arn.User)
|
||||
|
@ -42,6 +42,7 @@ func Get(ctx *aero.Context) string {
|
||||
|
||||
// Friends watching
|
||||
var friends []*arn.User
|
||||
friendsAnimeListItems := map[*arn.User]*arn.AnimeListItem{}
|
||||
|
||||
if user != nil {
|
||||
friends = user.Follows().Users()
|
||||
@ -49,9 +50,14 @@ func Get(ctx *aero.Context) string {
|
||||
deleted := 0
|
||||
for i := range friends {
|
||||
j := i - deleted
|
||||
if !friends[j].AnimeList().Contains(anime.ID) {
|
||||
friendAnimeList := friends[j].AnimeList()
|
||||
obj, err := friendAnimeList.Get(anime.ID)
|
||||
|
||||
if err != nil {
|
||||
friends = friends[:j+copy(friends[j:], friends[j+1:])]
|
||||
deleted++
|
||||
} else {
|
||||
friendsAnimeListItems[friends[j]] = obj.(*arn.AnimeListItem)
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,5 +94,5 @@ func Get(ctx *aero.Context) string {
|
||||
|
||||
ctx.Data = openGraph
|
||||
|
||||
return ctx.HTML(components.Anime(anime, friends, tracks, user, episodesReversed))
|
||||
return ctx.HTML(components.Anime(anime, friends, friendsAnimeListItems, tracks, user, episodesReversed))
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
component Anime(anime *arn.Anime, friends []*arn.User, tracks []*arn.SoundTrack, user *arn.User, episodesReversed bool)
|
||||
component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, tracks []*arn.SoundTrack, user *arn.User, episodesReversed bool)
|
||||
.anime-header(data-id=anime.ID)
|
||||
if anime.Image.Small != ""
|
||||
.anime-image-container
|
||||
@ -39,7 +39,16 @@ component Anime(anime *arn.Anime, friends []*arn.User, tracks []*arn.SoundTrack,
|
||||
h3.anime-section-name Friends
|
||||
|
||||
.anime-friends
|
||||
UserGrid(friends)
|
||||
.user-avatars
|
||||
each friend in friends
|
||||
if friend.Nick != ""
|
||||
if friend.IsActive()
|
||||
.mountable
|
||||
CustomAvatar(friend, listItems[friend].Link(friend.Nick), friend.Nick + " => " + listItems[friend].Status + " | " + toString(listItems[friend].Episodes) + " eps | " + fmt.Sprintf("%.1f", listItems[friend].Rating.Overall) + " rating")
|
||||
else
|
||||
.mountable
|
||||
.inactive-user
|
||||
Avatar(friend)
|
||||
|
||||
h3.anime-section-name Ratings
|
||||
.anime-rating-categories
|
||||
|
Loading…
Reference in New Issue
Block a user