Prevent TypeError and incorrect state updates for "pageLoadStates"

Page load state updates of an already closed chapter caused TypeErrors or incorrect state updates.
This commit is contained in:
schroda
2024-12-30 20:51:29 +01:00
parent 55dc9471d9
commit 7c98bab43b
9 changed files with 59 additions and 21 deletions

View File

@@ -88,10 +88,15 @@ const BaseReaderPage = ({
onError: ReaderPagerProps['onError'];
setRef?: (pagesIndex: number, ref: HTMLElement | null) => void;
}) => {
const { src } = props;
const isTabletWidth = MediaQuery.useIsTabletWidth();
const handleLoad = useCallback(() => onLoad?.(pagesIndex, isPrimaryPage), [onLoad, pagesIndex, isPrimaryPage]);
const handleError = useCallback(() => onError?.(pageIndex), [onError, pageIndex]);
const handleLoad = useCallback(
() => onLoad?.(pagesIndex, src, isPrimaryPage),
[onLoad, pagesIndex, src, isPrimaryPage],
);
const handleError = useCallback(() => onError?.(pageIndex, src), [onError, pageIndex, src]);
const updateRef = useCallback((element: HTMLElement | null) => setRef?.(pagesIndex, element), [pagesIndex, setRef]);
if (!display && !shouldLoad) {