From 5ac407057e93c48acab4d33796285c8d11ad75bc Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 30 Jul 2026 14:55:00 -0400 Subject: [PATCH] fix(search): link results to book detail page and add cover thumbnails Search results navigated to /bookshelf with no filters instead of the selected book's page. Results now link to /media/:id and display cover thumbnails, with cover URLs resolved server-side via ResolveMediaURL. Removes the dead selectedBook localStorage plumbing. --- internal/handlers/media.go | 4 ++++ web/src/search.ts | 30 ++++++++++-------------------- web/src/storage.ts | 10 ---------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/internal/handlers/media.go b/internal/handlers/media.go index 9688873..6618b09 100644 --- a/internal/handlers/media.go +++ b/internal/handlers/media.go @@ -1791,6 +1791,10 @@ func (mh *MediaHandler) SearchMediaItems(c *echo.Context) error { "results": []interface{}{}, }) } + for i := range results { + resolved := utils.ResolveMediaURL(results[i].LibraryID, results[i].CoverImagePath) + results[i].CoverImagePath = pgtype.Text{String: resolved, Valid: resolved != ""} + } return c.JSON(http.StatusOK, results) } diff --git a/web/src/search.ts b/web/src/search.ts index 83dffad..4719c89 100644 --- a/web/src/search.ts +++ b/web/src/search.ts @@ -1,5 +1,4 @@ import { Alpine } from "./alpine"; -import { setSelectedLibrary } from "./storage"; let searchInputTimeout: ReturnType | null = null; const SEARCH_DEBOUNCE_MS = 300; @@ -190,12 +189,6 @@ function showSearchResults(results: MediaItemSummary[], query: string, activeId? searchResults.dataset.selectedIndex = "-1"; - const libraryIconMap: Record = { - ebooks: "📚", - comics: "📖", - manga: "🗾", - }; - let html = `

@@ -206,19 +199,23 @@ function showSearchResults(results: MediaItemSummary[], query: string, activeId? `; results.forEach((item, index) => { - const icon = libraryIconMap[item.library_type_name] || "📁"; const titleHtml = highlightMatch(item.title, query); const authorHtml = item.author ? highlightMatch(item.author, query) : ""; + const coverUrl = item.cover_image_path || "/static/placeholder-book.svg"; html += `