From c07dba4eff9766474a12ec4e080dc8afe9890e20 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 17 Oct 2026 14:02:43 -0400 Subject: [PATCH] refactor(cards): smart-collection preview through the builder POST preview-feed had the ladder's 14th hand-rolled literal. Now BookCardsFromMediaItems + one LibraryTypeMap per request; the response carries format_group/badge values for the first time (all seven keys were already emitted as zero-value JSON, so this is a value change on a pin-frozen shape, not a key change). --- internal/handlers/collections.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/internal/handlers/collections.go b/internal/handlers/collections.go index 997b6317..e77d8260 100644 --- a/internal/handlers/collections.go +++ b/internal/handlers/collections.go @@ -1251,16 +1251,7 @@ func (h *CollectionHandler) PreviewCollection(c *echo.Context) error { matchedItems = matchedItems[:req.Limit] } - bookCards := make([]BookInfo, len(matchedItems)) - for i, item := range matchedItems { - itemUUID, _ := uuid.FromBytes(item.ID.Bytes[0:16]) - bookCards[i] = BookInfo{ - MediaItemID: itemUUID.String(), - Title: item.Title, - Author: textToString(item.Author), - CoverImagePath: utils.ResolveMediaURL(item.LibraryID, item.CoverImagePath), - } - } + bookCards := BookCardsFromMediaItems(matchedItems, LibraryTypeMap(c.Request().Context(), h.db)) return c.JSON(http.StatusOK, map[string]interface{}{"items": bookCards}) }