26 lines
723 B
TypeScript
26 lines
723 B
TypeScript
|
|
/*
|
||
|
|
* 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/.
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { ReaderResumeMode } from '@/modules/reader/types/Reader.types.ts';
|
||
|
|
|
||
|
|
export const getInitialReaderPageIndex = (
|
||
|
|
resumeMode: ReaderResumeMode,
|
||
|
|
lastReadPageIndex: number,
|
||
|
|
lastPageIndex: number,
|
||
|
|
): number => {
|
||
|
|
if (resumeMode === ReaderResumeMode.START) {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (resumeMode === ReaderResumeMode.END) {
|
||
|
|
return lastPageIndex;
|
||
|
|
}
|
||
|
|
|
||
|
|
return Math.max(0, Math.min(lastPageIndex, lastReadPageIndex));
|
||
|
|
};
|