refactor(cards): template search grid through the builder
router/search.go (the templ BooksGrid fragment surface) now uses BookCardsFromUnified — the unified row's LibraryTypeName column gives the badge with no LibraryTypeMap query; also drops that site's needless pgtype.UUID byte-roundtrip on the cover URL.
This commit is contained in:
1 parent
5adfb459d7
commit
0971e7debb
1 file changed
+1
-14
@@ -4,7 +4,6 @@ import (
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/handlers"
|
||||
"bookhoard/internal/services"
|
||||
"bookhoard/internal/utils"
|
||||
"bookhoard/templates"
|
||||
"bytes"
|
||||
"log"
|
||||
@@ -101,19 +100,7 @@ func handleSearchHTML(c *echo.Context, cfg *Config) error {
|
||||
return c.HTML(http.StatusInternalServerError, `<div style="color: red;">Search error</div>`)
|
||||
}
|
||||
// Convert to BookInfo
|
||||
bookInfoList := make([]handlers.BookInfo, len(results))
|
||||
for i, book := range results {
|
||||
bookUUID, _ := uuid.FromBytes(book.ID.Bytes[0:16])
|
||||
bookLibUUID, _ := uuid.FromBytes(book.LibraryID.Bytes[0:16])
|
||||
bookInfoList[i] = handlers.BookInfo{
|
||||
MediaItemID: bookUUID.String(),
|
||||
Title: book.Title,
|
||||
Author: textToString(book.Author),
|
||||
CoverImagePath: utils.ResolveMediaURL(pgtype.UUID{Bytes: bookLibUUID, Valid: true}, book.CoverImagePath),
|
||||
FormatGroup: book.FormatGroup,
|
||||
Badge: handlers.MediaBadgeKind(book.FormatGroup, book.LibraryTypeName),
|
||||
}
|
||||
}
|
||||
bookInfoList := handlers.BookCardsFromUnified(results)
|
||||
// Stamp active conflict flags so cards route the play action correctly
|
||||
bookInfoList = handlers.MarkActiveConflicts(c.Request().Context(), cfg.Queries, user.ID, bookInfoList)
|
||||
// Render using BooksGrid template (or BookPickerGrid for collection picker)
|
||||
|
||||
Reference in new issue
Block a user