Improve "page load state" updates

Changes of d6ff85fdd3 decreased the render performance due to the "onLoad" function changing and causing all pages to re-render.
This commit is contained in:
schroda
2024-12-29 17:21:37 +01:00
parent aee42d7bb1
commit c79f7cc874

View File

@@ -192,9 +192,15 @@ const BaseReaderViewer = forwardRef(
return;
}
setPageLoadStates((statePageLoadStates) => statePageLoadStates.toSpliced(index, 1, { loaded: true }));
setPageLoadStates((statePageLoadStates) => {
if (statePageLoadStates[index].loaded) {
return statePageLoadStates;
}
return statePageLoadStates.toSpliced(index, 1, { loaded: true });
});
},
[actualPages, readingMode, pageLoadStates],
[actualPages, readingMode],
);
const onError = useCallback((pageIndex: number) => {