diff --git a/internal/features/anime/handler.go b/internal/features/anime/handler.go index 31f493f..f080323 100644 --- a/internal/features/anime/handler.go +++ b/internal/features/anime/handler.go @@ -296,28 +296,6 @@ func (h *Handler) HandleAPIDiscoverUpcoming(w http.ResponseWriter, r *http.Reque templates.DiscoverItems(res.Animes, "upcoming", page+1, res.HasNextPage).Render(r.Context(), w) } -func (h *Handler) HandleSchedule(w http.ResponseWriter, r *http.Request) { - templates.Schedule().Render(r.Context(), w) -} - -func (h *Handler) HandleAPISchedule(w http.ResponseWriter, r *http.Request) { - day := r.URL.Query().Get("day") - if day == "" { - day = "monday" - } - - res, err := h.svc.GetSchedule(r.Context(), day) - if err != nil { - log.Printf("schedule error for %s: %v", day, err) - http.Error(w, "Failed to fetch schedule", http.StatusInternalServerError) - return - } - - res.Animes = deduplicateAnimes(res.Animes) - - templates.ScheduleDay(day, res.Animes).Render(r.Context(), w) -} - func (h *Handler) HandleNotifications(w http.ResponseWriter, r *http.Request) { userID := userIDFromRequest(r) @@ -326,14 +304,23 @@ func (h *Handler) HandleNotifications(w http.ResponseWriter, r *http.Request) { return } - watching, err := h.svc.GetWatchingAnime(r.Context(), userID) - if err != nil { - log.Printf("watching anime error: %v", err) - http.Error(w, "Failed to fetch watching anime", http.StatusInternalServerError) - return + tab := r.URL.Query().Get("tab") + if tab != "sequels" { + tab = "tracking" } - templates.Notifications(watching).Render(r.Context(), w) + var watching []templates.WatchingAnimeWithDetails + if tab == "tracking" { + var err error + watching, err = h.svc.GetWatchingAnime(r.Context(), userID) + if err != nil { + log.Printf("watching anime error: %v", err) + http.Error(w, "Failed to fetch watching anime", http.StatusInternalServerError) + return + } + } + + templates.Notifications(watching, tab).Render(r.Context(), w) } func (h *Handler) HandleNotificationsUpcoming(w http.ResponseWriter, r *http.Request) { diff --git a/internal/features/anime/service.go b/internal/features/anime/service.go index 5b3f8ce..ecca9da 100644 --- a/internal/features/anime/service.go +++ b/internal/features/anime/service.go @@ -61,10 +61,6 @@ func (s *Service) GetRelations(ctx context.Context, id int) ([]jikan.RelationEnt return s.jikanClient.GetFullRelations(ctx, id) } -func (s *Service) GetSchedule(ctx context.Context, day string) (jikan.ScheduleResult, error) { - return s.jikanClient.GetSchedule(ctx, day) -} - func (s *Service) GetRecommendations(ctx context.Context, animeID int, limit int) ([]jikan.Anime, error) { return s.jikanClient.GetRecommendations(ctx, animeID, limit) } diff --git a/internal/server/routes.go b/internal/server/routes.go index 9c05764..262b907 100644 --- a/internal/server/routes.go +++ b/internal/server/routes.go @@ -34,10 +34,8 @@ func NewRouter(cfg Config) http.Handler { mux.HandleFunc("/", animeHandler.HandleCatalog) mux.HandleFunc("/discover", animeHandler.HandleDiscover) - mux.HandleFunc("/schedule", animeHandler.HandleSchedule) mux.HandleFunc("/notifications", animeHandler.HandleNotifications) mux.HandleFunc("/notifications/upcoming", animeHandler.HandleNotificationsUpcoming) - mux.HandleFunc("/api/schedule", animeHandler.HandleAPISchedule) mux.HandleFunc("/api/discover/airing", animeHandler.HandleAPIDiscoverAiring) mux.HandleFunc("/api/discover/upcoming", animeHandler.HandleAPIDiscoverUpcoming) mux.HandleFunc("/search", animeHandler.HandleSearch) diff --git a/internal/templates/layout.templ b/internal/templates/layout.templ index 610684c..28e6895 100644 --- a/internal/templates/layout.templ +++ b/internal/templates/layout.templ @@ -8,12 +8,11 @@ templ Layout(title string) {
-Shows you're currently watching or planning to watch.
- - if len(watching) == 0 { - @ui.EmptyState("No airing anime in your watching list.") { - Add currently airing shows to your watching list to see upcoming episodes here. - } - } else { -Because you've watched prequels.
- -Shows you're currently watching or planning to watch.
+ if len(watching) == 0 { + @ui.EmptyState("No airing anime in your watching list.") { + Add currently airing shows to your watching list to see upcoming episodes here. + } + } else { +These are the currently airing anime, but you're not tracking any of these.
+Newly announced or upcoming seasons related to anime you've watched.
+Airing times in JST
- -No anime scheduled.
- } else { -