From 0971e7debba534c9a445b1ea67489d7a1260f45f Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 17 Oct 2026 14:04:36 -0400 Subject: [PATCH] refactor(cards): template search grid through the builder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- internal/router/search.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/internal/router/search.go b/internal/router/search.go index e40d3ad5..1fcaac0c 100644 --- a/internal/router/search.go +++ b/internal/router/search.go @@ -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, `
Search error
`) } // 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)