From 4d69e54c24502741304063153d907a97fe5d05c1 Mon Sep 17 00:00:00 2001 From: Sulthan Zaki Date: Thu, 30 Jul 2026 09:32:58 +0700 Subject: [PATCH] Count new chapters for the Updated tab badge The tab strip needs to say how many series have an unread chapter without the user opening the tab to find out, so listView carries the number alongside the filtered items. The count is taken over the whole reading set rather than the rendered items, so it means the same thing on every tab instead of collapsing to len(Items) on Updated and 0 everywhere else. Archived and finished are excluded, matching what the Updated tab itself shows. Co-Authored-By: Claude Opus 5 --- backend/web.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/web.go b/backend/web.go index 61f5840..59a7f79 100644 --- a/backend/web.go +++ b/backend/web.go @@ -38,6 +38,11 @@ type listView struct { Tab string // "all", "fav", or "new" Recent []Bookmark Items []Bookmark + // NewCount is the badge on the Updated tab: how many series being read + // have a chapter out that has not been read. It is counted over the whole + // reading set, not the active tab, so the badge does not change meaning as + // the user moves between tabs. + NewCount int } // Initial is the monogram the templates show in place of a cover when the @@ -178,12 +183,14 @@ func (h *webHandler) buildListView(tab string) (listView, error) { recent = recent[:recentCount] } + withNew := filterBookmarks(reading, func(b Bookmark) bool { return b.HasNewChapter() }) + var items []Bookmark switch tab { case "fav": items = filterBookmarks(reading, func(b Bookmark) bool { return b.Favorite }) case "new": - items = filterBookmarks(reading, func(b Bookmark) bool { return b.HasNewChapter() }) + items = withNew case "archived": items = filterBookmarks(all, func(b Bookmark) bool { return b.Status == statusArchived }) case "finished": @@ -192,7 +199,7 @@ func (h *webHandler) buildListView(tab string) (listView, error) { tab = "all" items = reading } - return listView{Tab: tab, Recent: recent, Items: items}, nil + return listView{Tab: tab, Recent: recent, Items: items, NewCount: len(withNew)}, nil } func (h *webHandler) uiList(w http.ResponseWriter, r *http.Request) {