refactor(cards): SSR series and tag pages through the builder

Both BrowseDetail surfaces hand-rolled bare 4-field literals (badges
dropped) and patched the nil-slice with []BookInfo{} seeds after.
BookCardsFromMediaItems feeds GetSeriesBooks/GetBooksByTag rows —
cards gain format_group + badge on the series and tag pages, and the
two seed blocks die with the adapter's non-nil empties. Conflict
stamping at these sites was already adjacent and is preserved.
This commit is contained in:
John O'Keefe committed 2026-10-17 14:05:09 -04:00
1 parent 0971e7debb
commit 8c56c9da55
1 file changed
+3 -29
+3 -29
View File
@@ -241,20 +241,7 @@ func registerFrontendRoutes(cfg *Config) {
log.Printf("GetSeriesBooks failed: %v", err)
errorMsg = "Error loading series books"
} else {
bookInfoList = make([]handlers.BookInfo, 0, len(books))
for _, item := range books {
itemUUID, _ := uuid.FromBytes(item.ID.Bytes[0:16])
bookInfoList = append(bookInfoList, handlers.BookInfo{
MediaItemID: itemUUID.String(),
Title: item.Title,
Author: textToString(item.Author),
CoverImagePath: utils.ResolveMediaURL(item.LibraryID, item.CoverImagePath),
})
}
}
if bookInfoList == nil {
bookInfoList = []handlers.BookInfo{}
bookInfoList = handlers.BookCardsFromMediaItems(books, handlers.LibraryTypeMap(c.Request().Context(), cfg.Queries))
}
seriesUserUUID, _ := uuid.Parse(user.ID)
@@ -295,23 +282,10 @@ func registerFrontendRoutes(cfg *Config) {
log.Printf("GetBooksByTag failed: %v", err)
errorMsg = "Error loading tag books"
} else {
bookInfoList = make([]handlers.BookInfo, 0, len(books))
for _, item := range books {
itemUUID, _ := uuid.FromBytes(item.ID.Bytes[0:16])
bookInfoList = append(bookInfoList, handlers.BookInfo{
MediaItemID: itemUUID.String(),
Title: item.Title,
Author: textToString(item.Author),
CoverImagePath: utils.ResolveMediaURL(item.LibraryID, item.CoverImagePath),
})
}
bookInfoList = handlers.BookCardsFromMediaItems(books, handlers.LibraryTypeMap(c.Request().Context(), cfg.Queries))
}
}
if bookInfoList == nil {
bookInfoList = []handlers.BookInfo{}
}
tagUserUUID, _ := uuid.Parse(user.ID)
bookInfoList = handlers.MarkActiveConflicts(c.Request().Context(), cfg.Queries, pgtype.UUID{Bytes: tagUserUUID, Valid: true}, bookInfoList)
@@ -1298,7 +1272,7 @@ func registerFrontendRoutes(cfg *Config) {
LibraryName: p.LibraryName,
SHA256: p.FileSha256,
SHAShort: p.FileSha256[:16] + "…",
CreatedAt: p.CreatedAt.Time.In(utils.UserLocation(user.Timezone)).Format("Jan 2, 2006"),
CreatedAt: p.CreatedAt.Time.In(utils.UserLocation(user.Timezone)).Format("Jan 2, 2006"),
Items: []templates.HashConflictItemData{},
}