mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-03 03:27:03 +00:00
fix(ui): handle library-open errors
Opening a book card swallowed failures: a corrupt or unreadable file failed silently and normalizeBook could throw on a missing chapters array. Surface load errors as a toast, throw a clear message on unparseable JSON, and make normalizeBook tolerant of missing chapters, metadata and settings. Claude-Session: https://claude.ai/code/session_01RzTWrLiy4zGuw2hZSQGamk
This commit is contained in:
1 parent
9eabef9041
commit
4e5ea6d855
3 files changed
+21
-5
No files matched your search
@@ -79,7 +79,11 @@ export function Library({ onOpen }: { onOpen: (book: Book) => void }) {
|
||||
</button>
|
||||
)}
|
||||
{books.map((b) => (
|
||||
<div key={b.id} className="card card-book" onClick={() => loadBook(b.id).then(onOpen)}>
|
||||
<div
|
||||
key={b.id}
|
||||
className="card card-book"
|
||||
onClick={() => loadBook(b.id).then(onOpen).catch((e) => setNotice(`Could not open book: ${e}`))}
|
||||
>
|
||||
<span className="card-title">{b.title || "Untitled"}</span>
|
||||
{b.author && <span className="card-author">{b.author}</span>}
|
||||
<RowMenu label="Book options" className="card-menu" onDelete={() => setPendingDelete(b)} />
|
||||
|
||||
Reference in new issue
Block a user