feat: replace notifications with continue watching
This commit is contained in:
@@ -314,51 +314,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) HandleNotifications(w http.ResponseWriter, r *http.Request) {
|
||||
userID := userIDFromRequest(r)
|
||||
|
||||
if userID == "" {
|
||||
http.Redirect(w, r, "/login", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
tab := r.URL.Query().Get("tab")
|
||||
if tab != "sequels" {
|
||||
tab = "tracking"
|
||||
}
|
||||
|
||||
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) {
|
||||
userID := userIDFromRequest(r)
|
||||
|
||||
if userID == "" {
|
||||
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
upcomingSeasons, err := h.svc.GetUpcomingSeasons(r.Context(), userID)
|
||||
if err != nil {
|
||||
log.Printf("upcoming seasons error: %v", err)
|
||||
http.Error(w, "Failed to fetch upcoming seasons", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
templates.UpcomingSeasonsList(upcomingSeasons).Render(r.Context(), w)
|
||||
}
|
||||
|
||||
func (h *Handler) HandleStudioDetails(w http.ResponseWriter, r *http.Request) {
|
||||
idStr := r.URL.Path[len("/studios/"):]
|
||||
id, err := strconv.Atoi(idStr)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"mal/internal/database"
|
||||
"mal/internal/jikan"
|
||||
"mal/internal/templates"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
@@ -98,52 +97,6 @@ func (s *Service) GetRecommendations(ctx context.Context, animeID int, limit int
|
||||
return s.jikanClient.GetRecommendations(ctx, animeID, limit)
|
||||
}
|
||||
|
||||
func (s *Service) GetWatchingAnime(ctx context.Context, userID string) ([]templates.WatchingAnimeWithDetails, error) {
|
||||
rows, err := s.db.GetWatchingAnime(ctx, userID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get watching anime: %w", err)
|
||||
}
|
||||
|
||||
var result []templates.WatchingAnimeWithDetails
|
||||
for _, row := range rows {
|
||||
anime, err := s.jikanClient.GetAnimeByID(ctx, int(row.AnimeID))
|
||||
if err != nil {
|
||||
if jikan.IsRetryableError(err) {
|
||||
s.jikanClient.EnqueueAnimeFetchRetry(ctx, int(row.AnimeID), err)
|
||||
}
|
||||
// Instead of skipping, we still append it, but without the extra Jikan details
|
||||
// This prevents anime from vanishing from the watchlist when Jikan rate limits us.
|
||||
anime = jikan.Anime{}
|
||||
}
|
||||
result = append(result, templates.WatchingAnimeWithDetails{
|
||||
Entry: row,
|
||||
Anime: anime,
|
||||
})
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetUpcomingSeasons(ctx context.Context, userID string) ([]database.GetUpcomingSeasonsRow, error) {
|
||||
rows, err := s.db.GetUpcomingSeasons(ctx, userID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get upcoming seasons: %w", err)
|
||||
}
|
||||
|
||||
// Deduplicate by related anime ID
|
||||
// Because of the recursive query, multiple prequels can point to the same upcoming season
|
||||
seen := make(map[int64]bool)
|
||||
var deduped []database.GetUpcomingSeasonsRow
|
||||
for _, row := range rows {
|
||||
if !seen[row.ID] {
|
||||
seen[row.ID] = true
|
||||
deduped = append(deduped, row)
|
||||
}
|
||||
}
|
||||
|
||||
return deduped, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetAnimeByProducer(ctx context.Context, producerID int, page int) (jikan.StudioAnimeResult, error) {
|
||||
return s.jikanClient.GetAnimeByProducer(ctx, producerID, page)
|
||||
}
|
||||
|
||||
@@ -173,14 +173,7 @@ func (h *Handler) HandleGetWatchlist(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var filteredEntries []database.GetUserWatchListRow
|
||||
if statusFilter == "continuing" {
|
||||
// Show airing anime with watching or plan_to_watch status
|
||||
for _, entry := range entries {
|
||||
if entry.Airing.Bool && (entry.Status == "watching" || entry.Status == "plan_to_watch") {
|
||||
filteredEntries = append(filteredEntries, entry)
|
||||
}
|
||||
}
|
||||
} else if statusFilter != "" && statusFilter != "all" {
|
||||
if statusFilter != "" && statusFilter != "all" {
|
||||
for _, entry := range entries {
|
||||
if entry.Status == statusFilter {
|
||||
filteredEntries = append(filteredEntries, entry)
|
||||
@@ -197,6 +190,59 @@ func (h *Handler) HandleGetWatchlist(w http.ResponseWriter, r *http.Request) {
|
||||
templates.Watchlist(filteredEntries, layout, statusFilter, sortBy, sortOrder).Render(r.Context(), w)
|
||||
}
|
||||
|
||||
func (h *Handler) HandleContinueWatching(w http.ResponseWriter, r *http.Request) {
|
||||
if !requireMethod(w, r, http.MethodGet) {
|
||||
return
|
||||
}
|
||||
|
||||
user := middleware.GetUser(r.Context())
|
||||
if user == nil {
|
||||
http.Redirect(w, r, "/login", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
entries, err := h.svc.db.GetContinueWatchingEntries(r.Context(), user.ID)
|
||||
if err != nil {
|
||||
log.Printf("continue watching fetch failed: user_id=%s err=%v", user.ID, err)
|
||||
http.Error(w, "failed to fetch continue watching", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
templates.ContinueWatching(entries).Render(r.Context(), w)
|
||||
}
|
||||
|
||||
func (h *Handler) HandleDeleteContinueWatching(w http.ResponseWriter, r *http.Request) {
|
||||
if !requireMethod(w, r, http.MethodDelete) {
|
||||
return
|
||||
}
|
||||
|
||||
user := middleware.GetUser(r.Context())
|
||||
if user == nil {
|
||||
w.Header().Set("HX-Redirect", "/login")
|
||||
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
path := r.URL.Path[len("/api/continue-watching/"):]
|
||||
animeID, err := strconv.ParseInt(path, 10, 64)
|
||||
if err != nil || animeID <= 0 {
|
||||
http.Error(w, "invalid anime ID", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
err = h.svc.db.DeleteContinueWatchingEntry(r.Context(), database.DeleteContinueWatchingEntryParams{
|
||||
UserID: user.ID,
|
||||
AnimeID: animeID,
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("continue watching delete failed: user_id=%s anime_id=%d err=%v", user.ID, animeID, err)
|
||||
http.Error(w, "failed to delete continue watching entry", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func (h *Handler) HandleExportWatchlist(w http.ResponseWriter, r *http.Request) {
|
||||
if !requireMethod(w, r, http.MethodGet) {
|
||||
return
|
||||
|
||||
@@ -41,8 +41,10 @@ func NewRouter(cfg Config) http.Handler {
|
||||
|
||||
mux.HandleFunc("/", animeHandler.HandleCatalog)
|
||||
mux.HandleFunc("/discover", animeHandler.HandleDiscover)
|
||||
mux.HandleFunc("/notifications", animeHandler.HandleNotifications)
|
||||
mux.HandleFunc("/notifications/upcoming", animeHandler.HandleNotificationsUpcoming)
|
||||
mux.HandleFunc("/continue-watching", watchlistHandler.HandleContinueWatching)
|
||||
mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/continue-watching", http.StatusMovedPermanently)
|
||||
})
|
||||
mux.HandleFunc("/api/discover/airing", animeHandler.HandleAPIDiscoverAiring)
|
||||
mux.HandleFunc("/api/discover/upcoming", animeHandler.HandleAPIDiscoverUpcoming)
|
||||
mux.HandleFunc("/search", animeHandler.HandleSearch)
|
||||
@@ -77,6 +79,7 @@ func NewRouter(cfg Config) http.Handler {
|
||||
mux.HandleFunc("/api/watchlist/import", watchlistHandler.HandleImportWatchlist)
|
||||
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,
|
||||
|
||||
@@ -6,6 +6,7 @@ type AnimeCardProps struct {
|
||||
ID int
|
||||
Title string
|
||||
ImageURL string
|
||||
Href string
|
||||
// Options to customize the card behavior
|
||||
Class string // override default wrapper class
|
||||
ImgClass string // override default image class
|
||||
@@ -24,7 +25,7 @@ templ AnimeCard(props AnimeCardProps) {
|
||||
{ children... }
|
||||
</div>
|
||||
} else {
|
||||
<a href={ templ.URL(fmt.Sprintf("/anime/%d", props.ID)) } class={ defaultString(props.Class, "flex flex-col bg-transparent text-inherit no-underline") }>
|
||||
<a href={ templ.URL(cardHref(props)) } class={ defaultString(props.Class, "flex flex-col bg-transparent text-inherit no-underline") }>
|
||||
@animeCardPoster(props.ImageURL, props.Title, props.ImgClass)
|
||||
|
||||
if !props.HideTitle {
|
||||
@@ -37,6 +38,14 @@ templ AnimeCard(props AnimeCardProps) {
|
||||
}
|
||||
}
|
||||
|
||||
func cardHref(props AnimeCardProps) string {
|
||||
if props.Href != "" {
|
||||
return props.Href
|
||||
}
|
||||
|
||||
return fmt.Sprintf("/anime/%d", props.ID)
|
||||
}
|
||||
|
||||
templ animeCardPoster(imageURL, title, imgClass string) {
|
||||
<div class="flex w-full aspect-2/3 justify-center overflow-hidden">
|
||||
if imageURL != "" {
|
||||
|
||||
67
internal/templates/continue_watching.templ
Normal file
67
internal/templates/continue_watching.templ
Normal file
@@ -0,0 +1,67 @@
|
||||
package templates
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"mal/internal/database"
|
||||
"mal/internal/shared/ui"
|
||||
)
|
||||
|
||||
templ ContinueWatching(entries []database.GetContinueWatchingEntriesRow) {
|
||||
@Layout("mal - continue watching", true) {
|
||||
<div class="grid gap-4">
|
||||
<h1>Continue watching</h1>
|
||||
<p class="m-0 text-sm text-(--text-muted)">Pick up where you left off.</p>
|
||||
if len(entries) == 0 {
|
||||
@ui.EmptyState("Nothing to continue yet") {
|
||||
Start watching any anime and your progress will show up here.
|
||||
}
|
||||
} else {
|
||||
<div class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 lg:grid-cols-4 xl:grid-cols-5">
|
||||
for _, entry := range entries {
|
||||
<div class="group relative min-w-0" id={ fmt.Sprintf("continue-entry-%d", entry.AnimeID) }>
|
||||
@ui.AnimeCard(ui.AnimeCardProps{
|
||||
ID: int(entry.AnimeID),
|
||||
Title: displayContinueWatchingTitle(entry),
|
||||
ImageURL: entry.ImageUrl,
|
||||
Href: continueWatchingURL(entry),
|
||||
Class: "notification-card min-w-0 flex flex-col bg-transparent text-inherit no-underline",
|
||||
HideTitle: true,
|
||||
}) {
|
||||
<div class="mt-2 grid gap-1 p-0">
|
||||
<div class="line-clamp-2 text-sm leading-snug text-(--text)">{ displayContinueWatchingTitle(entry) }</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
if entry.CurrentEpisode.Valid && entry.CurrentEpisode.Int64 > 0 {
|
||||
<span class="text-xs text-(--text-faint)">Continue ep { fmt.Sprintf("%d", entry.CurrentEpisode.Int64) }</span>
|
||||
}
|
||||
if entry.CurrentTimeSeconds > 0 {
|
||||
<span class="text-xs text-(--text-faint)">{ formatProgressTime(entry.CurrentTimeSeconds) }</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<button
|
||||
class="absolute right-2 top-2 h-6 w-6 cursor-pointer border-0 bg-(--overlay-subtle) text-(--text-muted) opacity-0 transition-opacity duration-150 group-hover:opacity-100 hover:text-(--danger)"
|
||||
hx-delete={ string(templ.URL(fmt.Sprintf("/api/continue-watching/%d", entry.AnimeID))) }
|
||||
hx-target={ fmt.Sprintf("#continue-entry-%d", entry.AnimeID) }
|
||||
hx-swap="delete"
|
||||
>×</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
func continueWatchingURL(entry database.GetContinueWatchingEntriesRow) string {
|
||||
episode := 1
|
||||
if entry.CurrentEpisode.Valid && entry.CurrentEpisode.Int64 > 0 {
|
||||
episode = int(entry.CurrentEpisode.Int64)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("/watch/%d/%d", entry.AnimeID, episode)
|
||||
}
|
||||
|
||||
func displayContinueWatchingTitle(entry database.GetContinueWatchingEntriesRow) string {
|
||||
return database.DisplayTitle(entry.TitleEnglish, entry.TitleJapanese, entry.TitleOriginal)
|
||||
}
|
||||
@@ -26,9 +26,8 @@ templ Layout(title string, showHeader bool) {
|
||||
@icons.LogoIcon("h-7 w-7")
|
||||
</a>
|
||||
<div class="flex flex-wrap gap-3 text-sm max-lg:w-full max-lg:gap-2">
|
||||
<a class="text-(--text-muted) no-underline hover:text-(--text) hover:no-underline" href="/">Catalog</a>
|
||||
<a class="text-(--text-muted) no-underline hover:text-(--text) hover:no-underline" href="/discover">Discover</a>
|
||||
<a class="text-(--text-muted) no-underline hover:text-(--text) hover:no-underline" href="/notifications">Notifications</a>
|
||||
<a class="text-(--text-muted) no-underline hover:text-(--text) hover:no-underline" href="/continue-watching">Continue watching</a>
|
||||
<a class="text-(--text-muted) no-underline hover:text-(--text) hover:no-underline" href="/watchlist">Watchlist</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
package templates
|
||||
|
||||
import "mal/internal/jikan"
|
||||
import "mal/internal/database"
|
||||
import "mal/internal/shared/ui"
|
||||
import "fmt"
|
||||
import "strings"
|
||||
|
||||
type WatchingAnimeWithDetails struct {
|
||||
Entry database.GetWatchingAnimeRow
|
||||
Anime jikan.Anime
|
||||
}
|
||||
|
||||
templ Notifications(watching []WatchingAnimeWithDetails, activeTab string) {
|
||||
@Layout("mal - notifications", true) {
|
||||
<div class="grid gap-4">
|
||||
<h1>Notifications</h1>
|
||||
<div class="mb-3 flex flex-wrap gap-2 max-md:flex-nowrap max-md:overflow-x-auto max-md:pb-1">
|
||||
<a href="/notifications?tab=tracking" class={ statusTabClass(activeTab == "tracking") }>Tracking</a>
|
||||
<a href="/notifications?tab=sequels" class={ statusTabClass(activeTab == "sequels") }>Sequels</a>
|
||||
</div>
|
||||
|
||||
if activeTab == "sequels" {
|
||||
<div hx-get="/notifications/upcoming" hx-trigger="load, every 15s" hx-swap="innerHTML">
|
||||
@ui.LoadingIndicator("Syncing sequel graphs...")
|
||||
</div>
|
||||
} else {
|
||||
<p class="m-0 text-sm text-(--text-muted)">Shows you're currently watching or planning to watch.</p>
|
||||
if len(watching) == 0 {
|
||||
@ui.EmptyState("No airing anime in your watching list.") {
|
||||
<span class="text-sm text-(--text-muted)">Add currently airing shows to your watching list to see upcoming episodes here.</span>
|
||||
}
|
||||
} else {
|
||||
<div class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 lg:grid-cols-4 xl:grid-cols-5">
|
||||
for _, item := range watching {
|
||||
@NotificationCard(item)
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
func splitUpcomingSeasons(items []database.GetUpcomingSeasonsRow) (airing []database.GetUpcomingSeasonsRow, upcoming []database.GetUpcomingSeasonsRow) {
|
||||
for _, item := range items {
|
||||
if item.Status.Valid && item.Status.String == "Currently Airing" {
|
||||
airing = append(airing, item)
|
||||
} else {
|
||||
upcoming = append(upcoming, item)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
templ UpcomingSeasonsList(upcomingSeasons []database.GetUpcomingSeasonsRow) {
|
||||
if len(upcomingSeasons) == 0 {
|
||||
@ui.EmptyState("No upcoming seasons for anime you've watched.") {
|
||||
<span class="text-sm text-(--text-muted)">As you watch more shows, new seasons will appear here.</span>
|
||||
}
|
||||
} else {
|
||||
@renderSplitSeasons(upcomingSeasons)
|
||||
}
|
||||
}
|
||||
|
||||
templ renderSplitSeasons(upcomingSeasons []database.GetUpcomingSeasonsRow) {
|
||||
if airing, upcoming := splitUpcomingSeasons(upcomingSeasons); true {
|
||||
if len(airing) > 0 {
|
||||
<section class="mb-4 grid gap-3">
|
||||
<h2 class="m-0 text-xl font-semibold leading-tight">Airing now</h2>
|
||||
<p class="m-0 text-sm text-(--text-muted)">These are the currently airing anime, but you're not tracking any of these.</p>
|
||||
<div class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 lg:grid-cols-4 xl:grid-cols-5">
|
||||
for _, item := range airing {
|
||||
@UpcomingSeasonCard(item)
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
|
||||
if len(upcoming) > 0 {
|
||||
<section class="grid gap-3">
|
||||
<h2 class="m-0 text-xl font-semibold leading-tight">Announced & upcoming</h2>
|
||||
<p class="m-0 text-sm text-(--text-muted)">Newly announced or upcoming seasons related to anime you've watched.</p>
|
||||
<div class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 lg:grid-cols-4 xl:grid-cols-5">
|
||||
for _, item := range upcoming {
|
||||
@UpcomingSeasonCard(item)
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ UpcomingSeasonCard(item database.GetUpcomingSeasonsRow) {
|
||||
@ui.AnimeCard(ui.AnimeCardProps{
|
||||
ID: int(item.ID),
|
||||
Title: displaySeasonTitle(item),
|
||||
ImageURL: item.ImageUrl,
|
||||
Class: "notification-card min-w-0 flex flex-col bg-transparent text-inherit no-underline",
|
||||
HideTitle: true,
|
||||
}) {
|
||||
<div class="mt-2 grid gap-1 p-0" data-notification-content>
|
||||
<div class="line-clamp-2 text-sm leading-snug text-(--text)">
|
||||
{ displaySeasonTitle(item) }
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
if item.Status.Valid {
|
||||
<span class="text-xs text-(--text-faint)">{ seasonStatusLabel(item.Status.String) }</span>
|
||||
}
|
||||
if strings.TrimSpace(item.PrequelTitle) != "" {
|
||||
<span class="text-xs text-(--text-faint)">{ fmt.Sprintf("Sequel to %s", item.PrequelTitle) }</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
func displaySeasonTitle(entry database.GetUpcomingSeasonsRow) string {
|
||||
return database.DisplayTitle(entry.TitleEnglish, entry.TitleJapanese, entry.TitleOriginal)
|
||||
}
|
||||
|
||||
templ NotificationCard(item WatchingAnimeWithDetails) {
|
||||
@ui.AnimeCard(ui.AnimeCardProps{
|
||||
ID: int(item.Entry.AnimeID),
|
||||
Title: displayTitle(item.Entry),
|
||||
ImageURL: item.Entry.ImageUrl,
|
||||
Class: "notification-card min-w-0 flex flex-col bg-transparent text-inherit no-underline",
|
||||
HideTitle: true,
|
||||
}) {
|
||||
<div class="mt-2 grid gap-1 p-0" data-notification-content>
|
||||
<div class="line-clamp-2 text-sm leading-snug text-(--text)">
|
||||
{ displayTitle(item.Entry) }
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
if item.Anime.Broadcast.String != "" {
|
||||
<span class="text-xs text-(--text-faint)" data-jst-text={ item.Anime.Broadcast.String } data-broadcast-day={ item.Anime.Broadcast.Day } data-broadcast-time={ item.Anime.Broadcast.Time } data-broadcast-timezone={ item.Anime.Broadcast.Timezone }>{ item.Anime.Broadcast.String }</span>
|
||||
<span class="text-xs text-(--text-faint)" data-next-airing="pending">Calculating next episode time...</span>
|
||||
}
|
||||
if item.Anime.Episodes > 0 {
|
||||
<span class="text-xs text-(--text-faint)">
|
||||
if item.Entry.CurrentEpisode.Valid {
|
||||
{ fmt.Sprintf("%d / %d eps", item.Entry.CurrentEpisode.Int64, item.Anime.Episodes) }
|
||||
} else {
|
||||
{ fmt.Sprintf("0 / %d eps", item.Anime.Episodes) }
|
||||
}
|
||||
</span>
|
||||
} else if item.Entry.CurrentEpisode.Valid && item.Entry.CurrentEpisode.Int64 > 0 {
|
||||
<span class="text-xs text-(--text-faint)">
|
||||
{ fmt.Sprintf("%d eps watched", item.Entry.CurrentEpisode.Int64) }
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
func displayTitle(entry database.GetWatchingAnimeRow) string {
|
||||
return database.DisplayTitle(entry.TitleEnglish, entry.TitleJapanese, entry.TitleOriginal)
|
||||
}
|
||||
|
||||
func seasonStatusLabel(status string) string {
|
||||
statusText := strings.TrimSpace(status)
|
||||
if statusText == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
if statusText == "Currently Airing" {
|
||||
return "Airing now"
|
||||
}
|
||||
|
||||
if statusText == "Not yet aired" {
|
||||
return "Upcoming"
|
||||
}
|
||||
|
||||
return statusText
|
||||
}
|
||||
|
||||
func statusTabClass(active bool) string {
|
||||
base := "shrink-0 whitespace-nowrap bg-(--panel-soft) px-2 py-1 text-xs text-(--text-muted) no-underline hover:bg-(--surface-tab-hover) hover:text-(--text) hover:no-underline"
|
||||
if active {
|
||||
return "shrink-0 whitespace-nowrap bg-(--surface-tab-active) px-2 py-1 text-xs text-(--accent) no-underline hover:no-underline"
|
||||
}
|
||||
return base
|
||||
}
|
||||
@@ -29,7 +29,6 @@ templ Watchlist(entries []database.GetUserWatchListRow, layout string, currentSt
|
||||
<div class="mb-3 flex flex-wrap gap-2 max-md:flex-nowrap max-md:overflow-x-auto max-md:pb-1">
|
||||
<a href={ templ.URL(watchlistURL(layout, "all", sortBy, sortOrder)) } class={ tabClass(currentStatus == "all") }>All</a>
|
||||
<a href={ templ.URL(watchlistURL(layout, "watching", sortBy, sortOrder)) } class={ tabClass(currentStatus == "watching") }>Watching</a>
|
||||
<a href={ templ.URL(watchlistURL(layout, "continuing", sortBy, sortOrder)) } class={ tabClass(currentStatus == "continuing") }>Continuing</a>
|
||||
<a href={ templ.URL(watchlistURL(layout, "on_hold", sortBy, sortOrder)) } class={ tabClass(currentStatus == "on_hold") }>On hold</a>
|
||||
<a href={ templ.URL(watchlistURL(layout, "plan_to_watch", sortBy, sortOrder)) } class={ tabClass(currentStatus == "plan_to_watch") }>Plan to watch</a>
|
||||
<a href={ templ.URL(watchlistURL(layout, "dropped", sortBy, sortOrder)) } class={ tabClass(currentStatus == "dropped") }>Dropped</a>
|
||||
@@ -40,8 +39,6 @@ templ Watchlist(entries []database.GetUserWatchListRow, layout string, currentSt
|
||||
@ui.EmptyState("Nothing here yet") {
|
||||
if currentStatus == "all" {
|
||||
Your watchlist is empty. <a href="/">Search for anime</a> to get started.
|
||||
} else if currentStatus == "continuing" {
|
||||
No airing anime with watching or plan to watch status.
|
||||
} else {
|
||||
No anime in this category.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user