refactor(cards): BuildSections through the builder
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.
This commit is contained in:
1 parent
2f9d5b8e45
commit
5adfb459d7
1 file changed
+1
-13
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user