2024-11-06 13:00:36 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
2024-12-22 00:41:56 +01:00
|
|
|
import { memo } from 'react';
|
2024-11-06 13:00:36 +01:00
|
|
|
import { BasePager } from '@/modules/reader/components/viewer/pager/BasePager.tsx';
|
|
|
|
|
import { ReaderPagerProps } from '@/modules/reader/types/Reader.types.ts';
|
|
|
|
|
import { createReaderPage } from '@/modules/reader/utils/ReaderPager.utils.tsx';
|
|
|
|
|
|
2024-12-22 00:41:56 +01:00
|
|
|
const BaseReaderPagedPager = ({
|
2024-12-07 04:47:28 +01:00
|
|
|
onLoad,
|
|
|
|
|
onError,
|
|
|
|
|
pageLoadStates,
|
|
|
|
|
retryFailedPagesKeyPrefix,
|
|
|
|
|
...props
|
|
|
|
|
}: ReaderPagerProps) => {
|
2024-11-06 13:00:36 +01:00
|
|
|
const { currentPageIndex, totalPages } = props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<BasePager
|
|
|
|
|
{...props}
|
2025-02-03 15:57:44 +01:00
|
|
|
createPage={(page, pagesIndex, shouldLoad, shouldDisplay, _setRef, ...baseProps) =>
|
2024-11-06 13:00:36 +01:00
|
|
|
createReaderPage(
|
|
|
|
|
page,
|
2024-12-22 00:42:33 +01:00
|
|
|
pagesIndex,
|
|
|
|
|
true,
|
2025-01-20 01:29:04 +01:00
|
|
|
pageLoadStates[page.primary.index].loaded,
|
2024-12-22 00:42:33 +01:00
|
|
|
onLoad,
|
|
|
|
|
onError,
|
2024-11-06 13:00:36 +01:00
|
|
|
shouldLoad,
|
2025-01-28 02:16:00 +01:00
|
|
|
shouldDisplay && shouldLoad && currentPageIndex === page.primary.index,
|
2024-11-06 13:00:36 +01:00
|
|
|
currentPageIndex,
|
|
|
|
|
totalPages,
|
2025-02-03 15:57:44 +01:00
|
|
|
...baseProps,
|
2024-12-07 04:47:28 +01:00
|
|
|
pageLoadStates[page.primary.index].error ? retryFailedPagesKeyPrefix : undefined,
|
2024-11-06 13:00:36 +01:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
slots={{
|
2024-12-16 21:14:18 +01:00
|
|
|
boxProps: {
|
2024-11-06 13:00:36 +01:00
|
|
|
sx: {
|
|
|
|
|
margin: 'auto',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
2024-12-22 00:41:56 +01:00
|
|
|
|
2025-02-03 15:10:13 +01:00
|
|
|
export const ReaderPagedPager = memo(BaseReaderPagedPager);
|