fix: align template data keys with template expectations

This commit is contained in:
2026-05-13 12:49:56 +02:00
parent 862961d262
commit c814e1d391
2 changed files with 21 additions and 20 deletions

View File

@@ -166,6 +166,15 @@ func (h *AnimeHandler) HandleBrowse(c *gin.Context) {
log.Printf("browse error: %v", err) log.Printf("browse error: %v", err)
} }
user, _ := c.Get("User")
watchlistMap := make(map[int]bool)
if u, ok := user.(*domain.User); ok {
entries, _ := h.watchlistSvc.GetWatchlist(c.Request.Context(), u.ID)
for _, e := range entries {
watchlistMap[int(e.AnimeID)] = true
}
}
if c.GetHeader("HX-Request") == "true" { if c.GetHeader("HX-Request") == "true" {
c.HTML(http.StatusOK, "browse.gohtml", gin.H{ c.HTML(http.StatusOK, "browse.gohtml", gin.H{
"_fragment": "anime_card_scroll", "_fragment": "anime_card_scroll",
@@ -179,21 +188,13 @@ func (h *AnimeHandler) HandleBrowse(c *gin.Context) {
"Sort": sort, "Sort": sort,
"Genres": genres, "Genres": genres,
"SFW": sfw, "SFW": sfw,
"WatchlistMap": watchlistMap,
}) })
return return
} }
genresList, _ := h.svc.GetGenres(c.Request.Context()) genresList, _ := h.svc.GetGenres(c.Request.Context())
user, _ := c.Get("User")
watchlistMap := make(map[int]bool)
if u, ok := user.(*domain.User); ok {
entries, _ := h.watchlistSvc.GetWatchlist(c.Request.Context(), u.ID)
for _, e := range entries {
watchlistMap[int(e.AnimeID)] = true
}
}
c.HTML(http.StatusOK, "browse.gohtml", gin.H{ c.HTML(http.StatusOK, "browse.gohtml", gin.H{
"CurrentPath": "/browse", "CurrentPath": "/browse",
"Query": q, "Query": q,

View File

@@ -107,7 +107,7 @@ func (h *WatchlistHandler) HandleGetWatchlist(c *gin.Context) {
} }
c.HTML(http.StatusOK, "watchlist.gohtml", gin.H{ c.HTML(http.StatusOK, "watchlist.gohtml", gin.H{
"Entries": entries, "AllEntries": entries,
"CurrentPath": "/watchlist", "CurrentPath": "/watchlist",
"User": user, "User": user,
}) })