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:
1 parent
0971e7debb
commit
8c56c9da55
1 file changed
+3
-29
@@ -241,20 +241,7 @@ func registerFrontendRoutes(cfg *Config) {
|
|||||||
log.Printf("GetSeriesBooks failed: %v", err)
|
log.Printf("GetSeriesBooks failed: %v", err)
|
||||||
errorMsg = "Error loading series books"
|
errorMsg = "Error loading series books"
|
||||||
} else {
|
} else {
|
||||||
bookInfoList = make([]handlers.BookInfo, 0, len(books))
|
bookInfoList = handlers.BookCardsFromMediaItems(books, handlers.LibraryTypeMap(c.Request().Context(), cfg.Queries))
|
||||||
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{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
seriesUserUUID, _ := uuid.Parse(user.ID)
|
seriesUserUUID, _ := uuid.Parse(user.ID)
|
||||||
@@ -295,23 +282,10 @@ func registerFrontendRoutes(cfg *Config) {
|
|||||||
log.Printf("GetBooksByTag failed: %v", err)
|
log.Printf("GetBooksByTag failed: %v", err)
|
||||||
errorMsg = "Error loading tag books"
|
errorMsg = "Error loading tag books"
|
||||||
} else {
|
} else {
|
||||||
bookInfoList = make([]handlers.BookInfo, 0, len(books))
|
bookInfoList = handlers.BookCardsFromMediaItems(books, handlers.LibraryTypeMap(c.Request().Context(), cfg.Queries))
|
||||||
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{}
|
|
||||||
}
|
|
||||||
|
|
||||||
tagUserUUID, _ := uuid.Parse(user.ID)
|
tagUserUUID, _ := uuid.Parse(user.ID)
|
||||||
bookInfoList = handlers.MarkActiveConflicts(c.Request().Context(), cfg.Queries, pgtype.UUID{Bytes: tagUserUUID, Valid: true}, bookInfoList)
|
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,
|
LibraryName: p.LibraryName,
|
||||||
SHA256: p.FileSha256,
|
SHA256: p.FileSha256,
|
||||||
SHAShort: p.FileSha256[:16] + "…",
|
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{},
|
Items: []templates.HashConflictItemData{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user