Added friend icons to the full episodes page

This commit is contained in:
Eduard Urbach 2018-11-14 07:36:42 +09:00
parent 791b14174f
commit c34a4b763b
2 changed files with 16 additions and 5 deletions

View File

@ -15,10 +15,22 @@ func Episodes(ctx *aero.Context) string {
user := utils.GetUser(ctx)
id := ctx.Get("id")
anime, err := arn.GetAnime(id)
episodeToFriends := map[int][]*arn.User{}
if user != nil {
for _, friend := range user.Follows().Users() {
friendAnimeList := friend.AnimeList()
friendAnimeListItem := friendAnimeList.Find(anime.ID)
if friendAnimeListItem != nil && !friendAnimeListItem.Private && len(episodeToFriends[friendAnimeListItem.Episodes]) < maxFriendsPerEpisode {
episodeToFriends[friendAnimeListItem.Episodes] = append(episodeToFriends[friendAnimeListItem.Episodes], friend)
}
}
}
if err != nil {
return ctx.Error(http.StatusNotFound, "Anime not found", err)
}
return ctx.HTML(components.AnimeEpisodes(anime, anime.Episodes().Items, nil, user, true))
return ctx.HTML(components.AnimeEpisodes(anime, anime.Episodes().Items, episodeToFriends, user, true))
}

View File

@ -23,7 +23,6 @@ component AnimeEpisodes(anime *arn.Anime, episodes []*arn.AnimeEpisode, episodeT
if validate.DateTime(episode.AiringDate.Start)
.episode-airing-date-start.utc-airing-date.no-tip(data-start-date=episode.AiringDate.Start, data-end-date=episode.AiringDate.End, data-episode-number=episode.Number)= episode.AiringDate.StartDateHuman()
if episodeToFriends != nil
.episode-friends
each friend in episodeToFriends[index+1]
AvatarNoLink(friend)
.episode-friends
each friend in episodeToFriends[index+1]
AvatarNoLink(friend)