Make chapter transition warnings optional
This commit is contained in:
@@ -73,6 +73,8 @@ const APP_METADATA_OBJECT: Record<AppMetadataKeys, undefined> = {
|
||||
autoScroll: undefined,
|
||||
shouldShowReadingModePreview: undefined,
|
||||
shouldShowTapZoneLayoutPreview: undefined,
|
||||
shouldInformAboutMissingChapter: undefined,
|
||||
shouldInformAboutScanlatorChange: undefined,
|
||||
};
|
||||
|
||||
export const VALID_APP_METADATA_KEYS = Object.keys(APP_METADATA_OBJECT);
|
||||
|
||||
@@ -85,6 +85,16 @@ export const ReaderBehaviourSettings = ({
|
||||
checked={settings.shouldUseAutoWebtoonMode}
|
||||
onChange={(_, checked) => updateSetting('shouldUseAutoWebtoonMode', checked)}
|
||||
/>
|
||||
<CheckboxInput
|
||||
label={t('reader.settings.chapter_transition.warning.missing_chapter')}
|
||||
checked={settings.shouldInformAboutMissingChapter}
|
||||
onChange={(_, checked) => updateSetting('shouldInformAboutMissingChapter', checked)}
|
||||
/>
|
||||
<CheckboxInput
|
||||
label={t('reader.settings.chapter_transition.warning.scanlator_change')}
|
||||
checked={settings.shouldInformAboutScanlatorChange}
|
||||
onChange={(_, checked) => updateSetting('shouldInformAboutScanlatorChange', checked)}
|
||||
/>
|
||||
<ReaderSettingAutoScroll
|
||||
autoScroll={settings.autoScroll}
|
||||
setAutoScroll={(...args) => updateSetting('autoScroll', ...args)}
|
||||
|
||||
@@ -59,6 +59,8 @@ const GLOBAL_READER_SETTING_OBJECT: Record<keyof IReaderSettingsGlobal, undefine
|
||||
autoScroll: undefined,
|
||||
shouldShowReadingModePreview: undefined,
|
||||
shouldShowTapZoneLayoutPreview: undefined,
|
||||
shouldInformAboutMissingChapter: undefined,
|
||||
shouldInformAboutScanlatorChange: undefined,
|
||||
};
|
||||
|
||||
export const GLOBAL_READER_SETTING_KEYS = Object.keys(GLOBAL_READER_SETTING_OBJECT);
|
||||
@@ -137,6 +139,8 @@ export const DEFAULT_READER_SETTINGS: IReaderSettings = {
|
||||
},
|
||||
shouldShowReadingModePreview: true,
|
||||
shouldShowTapZoneLayoutPreview: true,
|
||||
shouldInformAboutMissingChapter: true,
|
||||
shouldInformAboutScanlatorChange: true,
|
||||
};
|
||||
|
||||
export const READER_PROGRESS_BAR_POSITION_TO_PLACEMENT: Record<ProgressBarPosition, TooltipProps['placement']> = {
|
||||
|
||||
@@ -168,7 +168,8 @@ export class ReaderControls {
|
||||
|
||||
static useOpenChapter(): (offset: 'previous' | 'next') => void {
|
||||
const { t } = useTranslation();
|
||||
const { readingMode } = ReaderService.useSettings();
|
||||
const { readingMode, shouldInformAboutMissingChapter, shouldInformAboutScanlatorChange } =
|
||||
ReaderService.useSettings();
|
||||
const { currentChapter, previousChapter, nextChapter } = useReaderStateChaptersContext();
|
||||
|
||||
const openPreviousChapter = ReaderService.useNavigateToChapter(previousChapter, ReaderResumeMode.END);
|
||||
@@ -178,12 +179,26 @@ export class ReaderControls {
|
||||
(offset) => {
|
||||
switch (offset) {
|
||||
case 'previous':
|
||||
ReaderControls.checkNextChapterConsistency(t, offset, currentChapter, previousChapter)
|
||||
ReaderControls.checkNextChapterConsistency(
|
||||
t,
|
||||
offset,
|
||||
currentChapter,
|
||||
previousChapter,
|
||||
shouldInformAboutMissingChapter,
|
||||
shouldInformAboutScanlatorChange,
|
||||
)
|
||||
.then(openPreviousChapter)
|
||||
.catch(defaultPromiseErrorHandler('ReaderControls::checkNextChapterConsistency: previous'));
|
||||
break;
|
||||
case 'next':
|
||||
ReaderControls.checkNextChapterConsistency(t, offset, currentChapter, nextChapter)
|
||||
ReaderControls.checkNextChapterConsistency(
|
||||
t,
|
||||
offset,
|
||||
currentChapter,
|
||||
nextChapter,
|
||||
shouldInformAboutMissingChapter,
|
||||
shouldInformAboutScanlatorChange,
|
||||
)
|
||||
.then(openNextChapter)
|
||||
.catch(defaultPromiseErrorHandler('ReaderControls::checkNextChapterConsistency: next'));
|
||||
break;
|
||||
@@ -191,23 +206,34 @@ export class ReaderControls {
|
||||
throw new Error(`Unexpected "offset" (${offset})`);
|
||||
}
|
||||
},
|
||||
[t, currentChapter?.id, openPreviousChapter, openNextChapter, readingMode.value],
|
||||
[
|
||||
t,
|
||||
currentChapter?.id,
|
||||
openPreviousChapter,
|
||||
openNextChapter,
|
||||
readingMode.value,
|
||||
shouldInformAboutMissingChapter,
|
||||
shouldInformAboutScanlatorChange,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
private static async checkNextChapterConsistency(
|
||||
t: TFunction,
|
||||
offset: 'previous' | 'next',
|
||||
currentChapter?: TChapterReader | null,
|
||||
chapterToOpen?: TChapterReader | null,
|
||||
currentChapter: TChapterReader | null | undefined,
|
||||
chapterToOpen: TChapterReader | null | undefined,
|
||||
shouldInformAboutMissingChapter: boolean,
|
||||
shouldInformAboutScanlatorChange: boolean,
|
||||
): Promise<void> {
|
||||
if (!currentChapter || !chapterToOpen) {
|
||||
return;
|
||||
}
|
||||
|
||||
const missingChapters = Math.abs(currentChapter.chapterNumber - chapterToOpen.chapterNumber);
|
||||
const isSameScanlator = currentChapter.scanlator === chapterToOpen.scanlator;
|
||||
const isContinuousChapter = missingChapters <= 1;
|
||||
const isSameScanlator =
|
||||
!shouldInformAboutScanlatorChange || currentChapter.scanlator === chapterToOpen.scanlator;
|
||||
const isContinuousChapter = !shouldInformAboutMissingChapter || missingChapters <= 1;
|
||||
|
||||
const showWarning = !isSameScanlator || !isContinuousChapter;
|
||||
if (!showWarning) {
|
||||
|
||||
@@ -134,6 +134,8 @@ export interface IReaderSettingsGlobal {
|
||||
};
|
||||
shouldShowReadingModePreview: boolean;
|
||||
shouldShowTapZoneLayoutPreview: boolean;
|
||||
shouldInformAboutMissingChapter: boolean;
|
||||
shouldInformAboutScanlatorChange: boolean;
|
||||
}
|
||||
|
||||
export interface IReaderSettingsManga {
|
||||
|
||||
Reference in New Issue
Block a user