From c34a4b763bf341ce0e86567a97a1807fcd9b9736 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 14 Nov 2018 07:36:42 +0900 Subject: [PATCH] Added friend icons to the full episodes page --- pages/anime/episodes.go | 14 +++++++++++++- pages/anime/episodes.pixy | 7 +++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pages/anime/episodes.go b/pages/anime/episodes.go index d489a17d..6044736f 100644 --- a/pages/anime/episodes.go +++ b/pages/anime/episodes.go @@ -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)) } diff --git a/pages/anime/episodes.pixy b/pages/anime/episodes.pixy index 142ca6a8..f6addc14 100644 --- a/pages/anime/episodes.pixy +++ b/pages/anime/episodes.pixy @@ -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)