diff --git a/src/components/reader/PhotoswipeReader.tsx b/src/components/reader/PhotoswipeReader.tsx index d061424..89d0907 100644 --- a/src/components/reader/PhotoswipeReader.tsx +++ b/src/components/reader/PhotoswipeReader.tsx @@ -265,9 +265,7 @@ export function PhotoswipeReader({ book, pages, onClose, nextBook }: BookReaderP isDoublePage={isDoublePage} shouldShowDoublePage={(page) => shouldShowDoublePage(page, pages.length)} imageBlobUrls={imageBlobUrls} - getPageUrl={getPageUrl} isRTL={isRTL} - isPageLoading={isPageLoading} /> boolean; imageBlobUrls: Record; - getPageUrl: (pageNum: number) => string; isRTL: boolean; - isPageLoading?: (pageNum: number) => boolean; } export function PageDisplay({ @@ -18,9 +16,7 @@ export function PageDisplay({ isDoublePage, shouldShowDoublePage, imageBlobUrls, - getPageUrl, isRTL, - isPageLoading, }: PageDisplayProps) { const [isLoading, setIsLoading] = useState(true); const [hasError, setHasError] = useState(false); @@ -53,6 +49,21 @@ export function PageDisplay({ setSecondPageHasError(false); }, [currentPage, isDoublePage]); + // Reset error state when blob URL becomes available + useEffect(() => { + if (imageBlobUrls[currentPage] && hasError) { + setHasError(false); + setIsLoading(true); + } + }, [imageBlobUrls[currentPage], currentPage, hasError]); + + useEffect(() => { + if (imageBlobUrls[currentPage + 1] && secondPageHasError) { + setSecondPageHasError(false); + setSecondPageLoading(true); + } + }, [imageBlobUrls[currentPage + 1], currentPage, secondPageHasError]); + return (
@@ -99,15 +110,12 @@ export function PageDisplay({ Image non disponible
- ) : ( + ) : imageBlobUrls[currentPage] ? ( <> {/* eslint-disable-next-line @next/next/no-img-element */} {`Page - )} + ) : null}
{/* Page 2 (double page) */} @@ -166,17 +174,12 @@ export function PageDisplay({ Image non disponible - ) : ( + ) : imageBlobUrls[currentPage + 1] ? ( <> {/* eslint-disable-next-line @next/next/no-img-element */} {`Page - )} + ) : null} )}