Make chapter transition warnings optional

This commit is contained in:
schroda
2025-01-01 17:24:36 +01:00
parent e199b75756
commit 2944252d91
6 changed files with 58 additions and 8 deletions

View File

@@ -855,6 +855,12 @@
"title": "Auto webtoon mode" "title": "Auto webtoon mode"
}, },
"background_color": "Background color", "background_color": "Background color",
"chapter_transition": {
"warning": {
"missing_chapter": "Inform about missing chapters on chapter transition",
"scanlator_change": "Inform about changing scanlator on chapter transition"
}
},
"custom_filter": { "custom_filter": {
"brightness": "Custom brightness", "brightness": "Custom brightness",
"contrast": "Custom contrast", "contrast": "Custom contrast",

View File

@@ -73,6 +73,8 @@ const APP_METADATA_OBJECT: Record<AppMetadataKeys, undefined> = {
autoScroll: undefined, autoScroll: undefined,
shouldShowReadingModePreview: undefined, shouldShowReadingModePreview: undefined,
shouldShowTapZoneLayoutPreview: undefined, shouldShowTapZoneLayoutPreview: undefined,
shouldInformAboutMissingChapter: undefined,
shouldInformAboutScanlatorChange: undefined,
}; };
export const VALID_APP_METADATA_KEYS = Object.keys(APP_METADATA_OBJECT); export const VALID_APP_METADATA_KEYS = Object.keys(APP_METADATA_OBJECT);

View File

@@ -85,6 +85,16 @@ export const ReaderBehaviourSettings = ({
checked={settings.shouldUseAutoWebtoonMode} checked={settings.shouldUseAutoWebtoonMode}
onChange={(_, checked) => updateSetting('shouldUseAutoWebtoonMode', checked)} 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 <ReaderSettingAutoScroll
autoScroll={settings.autoScroll} autoScroll={settings.autoScroll}
setAutoScroll={(...args) => updateSetting('autoScroll', ...args)} setAutoScroll={(...args) => updateSetting('autoScroll', ...args)}

View File

@@ -59,6 +59,8 @@ const GLOBAL_READER_SETTING_OBJECT: Record<keyof IReaderSettingsGlobal, undefine
autoScroll: undefined, autoScroll: undefined,
shouldShowReadingModePreview: undefined, shouldShowReadingModePreview: undefined,
shouldShowTapZoneLayoutPreview: undefined, shouldShowTapZoneLayoutPreview: undefined,
shouldInformAboutMissingChapter: undefined,
shouldInformAboutScanlatorChange: undefined,
}; };
export const GLOBAL_READER_SETTING_KEYS = Object.keys(GLOBAL_READER_SETTING_OBJECT); export const GLOBAL_READER_SETTING_KEYS = Object.keys(GLOBAL_READER_SETTING_OBJECT);
@@ -137,6 +139,8 @@ export const DEFAULT_READER_SETTINGS: IReaderSettings = {
}, },
shouldShowReadingModePreview: true, shouldShowReadingModePreview: true,
shouldShowTapZoneLayoutPreview: true, shouldShowTapZoneLayoutPreview: true,
shouldInformAboutMissingChapter: true,
shouldInformAboutScanlatorChange: true,
}; };
export const READER_PROGRESS_BAR_POSITION_TO_PLACEMENT: Record<ProgressBarPosition, TooltipProps['placement']> = { export const READER_PROGRESS_BAR_POSITION_TO_PLACEMENT: Record<ProgressBarPosition, TooltipProps['placement']> = {

View File

@@ -168,7 +168,8 @@ export class ReaderControls {
static useOpenChapter(): (offset: 'previous' | 'next') => void { static useOpenChapter(): (offset: 'previous' | 'next') => void {
const { t } = useTranslation(); const { t } = useTranslation();
const { readingMode } = ReaderService.useSettings(); const { readingMode, shouldInformAboutMissingChapter, shouldInformAboutScanlatorChange } =
ReaderService.useSettings();
const { currentChapter, previousChapter, nextChapter } = useReaderStateChaptersContext(); const { currentChapter, previousChapter, nextChapter } = useReaderStateChaptersContext();
const openPreviousChapter = ReaderService.useNavigateToChapter(previousChapter, ReaderResumeMode.END); const openPreviousChapter = ReaderService.useNavigateToChapter(previousChapter, ReaderResumeMode.END);
@@ -178,12 +179,26 @@ export class ReaderControls {
(offset) => { (offset) => {
switch (offset) { switch (offset) {
case 'previous': case 'previous':
ReaderControls.checkNextChapterConsistency(t, offset, currentChapter, previousChapter) ReaderControls.checkNextChapterConsistency(
t,
offset,
currentChapter,
previousChapter,
shouldInformAboutMissingChapter,
shouldInformAboutScanlatorChange,
)
.then(openPreviousChapter) .then(openPreviousChapter)
.catch(defaultPromiseErrorHandler('ReaderControls::checkNextChapterConsistency: previous')); .catch(defaultPromiseErrorHandler('ReaderControls::checkNextChapterConsistency: previous'));
break; break;
case 'next': case 'next':
ReaderControls.checkNextChapterConsistency(t, offset, currentChapter, nextChapter) ReaderControls.checkNextChapterConsistency(
t,
offset,
currentChapter,
nextChapter,
shouldInformAboutMissingChapter,
shouldInformAboutScanlatorChange,
)
.then(openNextChapter) .then(openNextChapter)
.catch(defaultPromiseErrorHandler('ReaderControls::checkNextChapterConsistency: next')); .catch(defaultPromiseErrorHandler('ReaderControls::checkNextChapterConsistency: next'));
break; break;
@@ -191,23 +206,34 @@ export class ReaderControls {
throw new Error(`Unexpected "offset" (${offset})`); 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( private static async checkNextChapterConsistency(
t: TFunction, t: TFunction,
offset: 'previous' | 'next', offset: 'previous' | 'next',
currentChapter?: TChapterReader | null, currentChapter: TChapterReader | null | undefined,
chapterToOpen?: TChapterReader | null, chapterToOpen: TChapterReader | null | undefined,
shouldInformAboutMissingChapter: boolean,
shouldInformAboutScanlatorChange: boolean,
): Promise<void> { ): Promise<void> {
if (!currentChapter || !chapterToOpen) { if (!currentChapter || !chapterToOpen) {
return; return;
} }
const missingChapters = Math.abs(currentChapter.chapterNumber - chapterToOpen.chapterNumber); const missingChapters = Math.abs(currentChapter.chapterNumber - chapterToOpen.chapterNumber);
const isSameScanlator = currentChapter.scanlator === chapterToOpen.scanlator; const isSameScanlator =
const isContinuousChapter = missingChapters <= 1; !shouldInformAboutScanlatorChange || currentChapter.scanlator === chapterToOpen.scanlator;
const isContinuousChapter = !shouldInformAboutMissingChapter || missingChapters <= 1;
const showWarning = !isSameScanlator || !isContinuousChapter; const showWarning = !isSameScanlator || !isContinuousChapter;
if (!showWarning) { if (!showWarning) {

View File

@@ -134,6 +134,8 @@ export interface IReaderSettingsGlobal {
}; };
shouldShowReadingModePreview: boolean; shouldShowReadingModePreview: boolean;
shouldShowTapZoneLayoutPreview: boolean; shouldShowTapZoneLayoutPreview: boolean;
shouldInformAboutMissingChapter: boolean;
shouldInformAboutScanlatorChange: boolean;
} }
export interface IReaderSettingsManga { export interface IReaderSettingsManga {