diff --git a/pages/anime/anime.go b/pages/anime/anime.go index db368846..e4c57768 100644 --- a/pages/anime/anime.go +++ b/pages/anime/anime.go @@ -70,6 +70,13 @@ func Get(ctx *aero.Context) string { return tracks[i].Title < tracks[j].Title }) + // Anime list item + var animeListItem *arn.AnimeListItem + + if user != nil { + animeListItem = user.AnimeList().Find(anime.ID) + } + // Open Graph description := anime.Summary @@ -100,5 +107,5 @@ func Get(ctx *aero.Context) string { ctx.Data = openGraph - return ctx.HTML(components.Anime(anime, tracks, episodes, friends, friendsAnimeListItems, user)) + return ctx.HTML(components.Anime(anime, animeListItem, tracks, episodes, friends, friendsAnimeListItems, user)) } diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index ffdf8461..69e3c084 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -1,11 +1,11 @@ -component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User) +component Anime(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User) .anime .anime-main-column - AnimeMainColumn(anime, tracks, episodes, user) + AnimeMainColumn(anime, listItem, tracks, episodes, user) .anime-side-column AnimeSideColumn(anime, friends, listItems, user) -component AnimeMainColumn(anime *arn.Anime, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, user *arn.User) +component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, user *arn.User) .anime-header(data-id=anime.ID) .anime-image-container.mountable img.anime-cover-image.lazy(data-src=anime.Image("large"), data-webp="true", alt=anime.Title.ByUser(user)) @@ -23,7 +23,7 @@ component AnimeMainColumn(anime *arn.Anime, tracks []*arn.SoundTrack, episodes [ .anime-summary-footer-container .anime-summary-footer AnimeGenres(anime) - AnimeActions(anime, user) + AnimeActions(anime, listItem, user) AnimeCharacters(anime) AnimeRelations(anime, user) @@ -38,7 +38,7 @@ component AnimeSideColumn(anime *arn.Anime, friends []*arn.User, listItems map[* AnimeFriends(friends, listItems) AnimeLinks(anime) -component AnimeActions(anime *arn.Anime, user *arn.User) +component AnimeActions(anime *arn.Anime, listItem *arn.AnimeListItem, user *arn.User) if user != nil .buttons.anime-actions if user.Role == "editor" || user.Role == "admin" @@ -46,10 +46,10 @@ component AnimeActions(anime *arn.Anime, user *arn.User) Icon("pencil-square-o") span Edit anime - if user.AnimeList().Contains(anime.ID) + if listItem != nil a.button.mountable.ajax(href="/+" + user.Nick + "/animelist/anime/" + anime.ID, data-mountable-type="footer") Icon("pencil") - span Edit in collection + span= listItem.StatusHumanReadable() else button.mountable.action(data-api="/api/animelist/" + user.ID, data-action="addAnimeToCollection", data-trigger="click", data-anime-id=anime.ID, data-mountable-type="footer") Icon("plus")