fix: pass watchlist status to anime detail page

Anime detail page never looked up or passed the user's watchlist
status, so the dropdown always showed 'Add to Watchlist'. Now
queries watch_list_entry and passes Status and WatchlistIDs.
This commit is contained in:
2026-05-13 18:18:22 +02:00
parent 413ee70923
commit 6c45a80623
4 changed files with 23 additions and 0 deletions

View File

@@ -253,9 +253,17 @@ func (h *AnimeHandler) HandleAnimeDetails(c *gin.Context) {
}
user, _ := c.Get("User")
status := ""
var watchlistIDs []int64
ep := 1
var cwSeconds float64
if u, ok := user.(*domain.User); ok {
entry, err := h.watchlistSvc.GetWatchListEntry(c.Request.Context(), u.ID, int64(id))
if err == nil {
status = entry.Status
watchlistIDs = []int64{entry.AnimeID}
}
cwEntry, err := h.watchlistSvc.GetContinueWatchingEntry(c.Request.Context(), u.ID, int64(id))
if err == nil && cwEntry.CurrentEpisode.Valid {
ep = int(cwEntry.CurrentEpisode.Int64)
@@ -267,6 +275,8 @@ func (h *AnimeHandler) HandleAnimeDetails(c *gin.Context) {
"Anime": anime,
"CurrentPath": fmt.Sprintf("/anime/%d", id),
"User": user,
"Status": status,
"WatchlistIDs": watchlistIDs,
"ContinueWatchingEp": ep,
"ContinueWatchingTime": cwSeconds,
})