mirror of
https://github.com/readest/readest.git
synced 2026-07-09 16:00:16 +00:00
fix(reader): guard applyMarginAndGap against a torn-down view (#5022)
applyMarginAndGap re-fetches getViewSettings(bookKey) with a non-null assertion, but it runs from effects/observers that can fire after the book is torn down, when getViewSettings returns null. The `!` hid that, so getViewInsets / viewSettings.showHeader threw "Cannot read properties of null (reading 'showHeader')" (READEST-2V). Bail when there is no view left to lay out. Fixes READEST-2V Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a9fb86ddc5
commit
fdd13a5a6a
1 changed files with 6 additions and 1 deletions
|
|
@ -779,7 +779,12 @@ const FoliateViewer: React.FC<{
|
|||
}, []);
|
||||
|
||||
const applyMarginAndGap = () => {
|
||||
const viewSettings = getViewSettings(bookKey)!;
|
||||
// Invoked from effects/observers that can fire after the book is torn down,
|
||||
// when getViewSettings(bookKey) returns null. The `!` assertion hid that, so
|
||||
// the reads below (getViewInsets, viewSettings.showHeader) crashed on null
|
||||
// (READEST-2V). Bail: there is no view left to lay out.
|
||||
const viewSettings = getViewSettings(bookKey);
|
||||
if (!viewSettings) return;
|
||||
const viewState = getViewState(bookKey);
|
||||
const bookData = getBookData(bookKey);
|
||||
const viewInsets = getViewInsets(viewSettings);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue