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:
@@ -253,10 +253,22 @@ func (h *AnimeHandler) HandleAnimeDetails(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user, _ := c.Get("User")
|
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{
|
c.HTML(http.StatusOK, "anime.gohtml", gin.H{
|
||||||
"Anime": anime,
|
"Anime": anime,
|
||||||
"CurrentPath": fmt.Sprintf("/anime/%d", id),
|
"CurrentPath": fmt.Sprintf("/anime/%d", id),
|
||||||
"User": user,
|
"User": user,
|
||||||
|
"ContinueWatchingEp": ep,
|
||||||
|
"ContinueWatchingTime": cwSeconds,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
{{if $anime.ShortRating}}<span class="flex items-center gap-1.5"><span>•</span>{{$anime.ShortRating}}</span>{{end}}
|
{{if $anime.ShortRating}}<span class="flex items-center gap-1.5"><span>•</span>{{$anime.ShortRating}}</span>{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{template "watchlist_actions" dict "Anime" $anime "User" .User "Status" .Status}}
|
{{template "watchlist_actions" dict "Anime" $anime "User" .User "Status" .Status "ContinueWatchingEp" .ContinueWatchingEp "ContinueWatchingTime" .ContinueWatchingTime}}
|
||||||
|
|
||||||
<div class="flex flex-col gap-12 lg:flex-row">
|
<div class="flex flex-col gap-12 lg:flex-row">
|
||||||
<div class="grow lg:max-w-4xl">
|
<div class="grow lg:max-w-4xl">
|
||||||
|
|||||||
@@ -46,9 +46,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</ui-dropdown>
|
</ui-dropdown>
|
||||||
|
|
||||||
<a href="/anime/{{$anime.MalID}}/watch" class="bg-background-button hover:bg-background-button-hover px-5 py-2.5 text-sm font-medium text-foreground transition-colors">
|
<a href="/anime/{{$anime.MalID}}/watch{{if and .ContinueWatchingEp (ne .ContinueWatchingEp 1)}}?ep={{.ContinueWatchingEp}}{{end}}" class="bg-background-button hover:bg-background-button-hover px-5 py-2.5 text-sm font-medium text-foreground transition-colors">
|
||||||
<i class="fa-solid fa-play mr-2"></i>
|
{{if and .ContinueWatchingEp (ne .ContinueWatchingEp 1)}}Continue Episode {{.ContinueWatchingEp}}{{else}}Watch Now{{end}}
|
||||||
Watch Now
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user