From 5adfb459d7ca0c4f88f2b300449ece5aa8c989c7 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 17 Oct 2026 14:04:14 -0400 Subject: [PATCH] refactor(cards): BuildSections through the builder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dashboard section builder — feeding both the dashboard JSON pin surface and the SSR dashboard — now calls BookCardsFromMediaItems on ds.Items. libTypes already arrives as a BuildSections parameter (once per request); the literal only duplicated the badge lookup. --- internal/handlers/dashboard.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/internal/handlers/dashboard.go b/internal/handlers/dashboard.go index 81610b2f..6a6e578d 100644 --- a/internal/handlers/dashboard.go +++ b/internal/handlers/dashboard.go @@ -3,7 +3,6 @@ package handlers import ( "bookhoard/internal/database" "bookhoard/internal/services" - "bookhoard/internal/utils" "context" "log" "net/http" @@ -200,18 +199,7 @@ func BuildSections(sections []services.DashboardSection, currentLibraryID, libra } } - bookCards := make([]BookInfo, len(ds.Items)) - for i, item := range ds.Items { - 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), - FormatGroup: item.FormatGroup, - Badge: MediaBadgeKind(item.FormatGroup, libTypes[uuid.UUID(item.LibraryID.Bytes).String()]), - } - } + bookCards := BookCardsFromMediaItems(ds.Items, libTypes) result = append(result, SectionData{ ID: ds.CollectionName,