From ee46f5568c21b34b1f668d3cded56597f90908e5 Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 11 Aug 2026 21:47:12 -0400 Subject: [PATCH] fix: resume epub progress from the fields the API returns The load function read progress.epub_loc and progress.progress, neither of which BookProgressRead carries, so resuming never worked and every open started at page one. Read epub_cfi and percentage instead. Fail loudly when the book cannot be fetched. The previous version caught everything and returned {status, error} that nothing consumed, so a missing book produced a reader sitting on its spinner forever. Check response.ok before parsing too: fetch resolves on a 404, and arrayBuffer() happily returns the error page, which only surfaced later as an opaque epub parse error. Give the reader a working sidebar, a theme that survives the book's own CSS, and an error state with a retry. The theme is registered rather than applied as bare overrides because most EPUBs ship their own body colours and win otherwise, which is why the page stayed white against a dark UI. --- .../lib/components/reader/epub-reader.svelte | 487 +++++++++++------- .../[bookId]/read/epub/[fileId]/+page.svelte | 29 +- .../book/[bookId]/read/epub/[fileId]/+page.ts | 40 +- 3 files changed, 329 insertions(+), 227 deletions(-) diff --git a/frontend/src/lib/components/reader/epub-reader.svelte b/frontend/src/lib/components/reader/epub-reader.svelte index 84a630a..f197745 100644 --- a/frontend/src/lib/components/reader/epub-reader.svelte +++ b/frontend/src/lib/components/reader/epub-reader.svelte @@ -1,272 +1,311 @@ - - + + +

Chapters

+
- Chapters - {#each chapters as chapter} + {#each chapters as chapter (chapter.href)} {#if chapter.subitems.length > 0}
- await navigateToChapter(chapter)} - > + navigateToChapter(chapter)}> {chapter.label}
- {#each chapter.subitems as subchapter} + {#each chapter.subitems as subchapter (subchapter.href)} await navigateToChapter(subchapter)} + onclick={() => navigateToChapter(subchapter)} > - {subchapter.label} + + {subchapter.label} + {/each} @@ -275,10 +314,7 @@
{:else} - await navigateToChapter(chapter)} - > + navigateToChapter(chapter)}> {chapter.label} @@ -286,68 +322,119 @@ {/each}
-
-
-
- {#if browser} - {#if !isReaderVisible} -
- -
+ +
+ +
+ + + (isSidebarOpen = !isSidebarOpen)} + disabled={!isReaderVisible} + > + + +

Chapters

+
+
+ + + {title || 'Reader'} + + + {#if isReaderVisible} + {/if} -
-
- -
+ +
-
- -
- + {#if loadError} + +
+
+ +

This book wouldn't open

+

{loadError}

+
+ + + Back to book + +
+ {:else if !isReaderVisible} +
+ + Opening… +
{/if} + + +
+ + +
+ + +