Resume chapter at specific page
- open from outside reader - is read - yes: 1st page - no : last read page - inside reader via - chapter selection: first page - previous chapter : last page - next chapter : first page
This commit is contained in:
25
src/modules/reader/utils/Reader.utils.ts
Normal file
25
src/modules/reader/utils/Reader.utils.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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));
|
||||
};
|
||||
Reference in New Issue
Block a user