feat: use saved progress for watch button on anime page

Check continue_watching_entry to find the episode to resume from.
Show 'Continue Episode N' instead of 'Watch Now' when progress exists.
This commit is contained in:
2026-05-13 18:16:25 +02:00
parent 851c9d701f
commit 413ee70923
3 changed files with 18 additions and 7 deletions

View File

@@ -253,10 +253,22 @@ func (h *AnimeHandler) HandleAnimeDetails(c *gin.Context) {
}
user, _ := c.Get("User")
ep := 1
var cwSeconds float64
if u, ok := user.(*domain.User); ok {
cwEntry, err := h.watchlistSvc.GetContinueWatchingEntry(c.Request.Context(), u.ID, int64(id))
if err == nil && cwEntry.CurrentEpisode.Valid {
ep = int(cwEntry.CurrentEpisode.Int64)
cwSeconds = cwEntry.CurrentTimeSeconds
}
}
c.HTML(http.StatusOK, "anime.gohtml", gin.H{
"Anime": anime,
"CurrentPath": fmt.Sprintf("/anime/%d", id),
"User": user,
"Anime": anime,
"CurrentPath": fmt.Sprintf("/anime/%d", id),
"User": user,
"ContinueWatchingEp": ep,
"ContinueWatchingTime": cwSeconds,
})
}