diff --git a/api/watchlist/handler.go b/api/watchlist/handler.go index 2b13c9e..506ebda 100644 --- a/api/watchlist/handler.go +++ b/api/watchlist/handler.go @@ -82,7 +82,26 @@ func (h *Handler) HandleDeleteWatchlist(w http.ResponseWriter, r *http.Request) } func (h *Handler) HandleDeleteContinueWatching(w http.ResponseWriter, r *http.Request) { - http.Error(w, "Not implemented", http.StatusNotImplemented) + user := middleware.GetUser(r.Context()) + if user == nil { + http.Error(w, "unauthorized", http.StatusUnauthorized) + return + } + + animeIDStr := r.URL.Path[len("/api/continue-watching/"):] + animeID, err := strconv.ParseInt(animeIDStr, 10, 64) + if err != nil { + http.Error(w, "invalid anime id", http.StatusBadRequest) + return + } + + if err := h.service.DeleteContinueWatching(r.Context(), user.ID, animeID); err != nil { + log.Printf("failed to remove from continue watching: %v", err) + http.Error(w, "failed to remove from continue watching", http.StatusInternalServerError) + return + } + + w.WriteHeader(http.StatusOK) } func (h *Handler) HandleGetWatchlist(w http.ResponseWriter, r *http.Request) { diff --git a/internal/server/routes.go b/internal/server/routes.go index ac09018..e355367 100644 --- a/internal/server/routes.go +++ b/internal/server/routes.go @@ -101,6 +101,7 @@ func NewRouter(cfg Config) http.Handler { mux.HandleFunc("/api/watchlist/card", watchlistHandler.HandleCardWatchlist) mux.HandleFunc("/api/watchlist", watchlistHandler.HandleUpdateWatchlist) mux.HandleFunc("/api/watchlist/", watchlistHandler.HandleDeleteWatchlist) + mux.HandleFunc("/api/continue-watching/", watchlistHandler.HandleDeleteContinueWatching) mux.HandleFunc("/watchlist", watchlistHandler.HandleGetWatchlist) // Wrap mux with global CSRF origin verification and auth checking diff --git a/templates/components/continue_watching.gohtml b/templates/components/continue_watching.gohtml index e15f5a3..8e43a92 100644 --- a/templates/components/continue_watching.gohtml +++ b/templates/components/continue_watching.gohtml @@ -7,13 +7,15 @@ {{$title := .TitleOriginal}} {{if .TitleEnglish.Valid}}{{$title = .TitleEnglish.String}}{{end}} - +
- {{$title}} + + {{$title}} + -
-
-
@@ -28,14 +30,16 @@
-

- {{$title}} -

-

- {{if .CurrentEpisode.Valid}}Episode {{.CurrentEpisode.Int64}}{{end}} -

+ +

+ {{$title}} +

+

+ {{if .CurrentEpisode.Valid}}Episode {{.CurrentEpisode.Int64}}{{end}} +

+
- +
{{end}}