From cf393b217b7a03f4c543c1dac118ddedf5552823 Mon Sep 17 00:00:00 2001 From: MCAxiaz Date: Sun, 8 Jan 2023 12:40:23 -0800 Subject: [PATCH] Add Reader Setting to Skip Dupe Chapters (#8831) Add reader setting to filter dupe chapters with same scanlator priority. --- .../more/settings/screen/SettingsReaderScreen.kt | 4 ++++ .../eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt | 10 ++++++++++ .../tachiyomi/ui/reader/setting/ReaderPreferences.kt | 2 ++ i18n/src/main/res/values/strings.xml | 1 + 4 files changed, 17 insertions(+) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt index cc327de21..d96a0cfdf 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt @@ -135,6 +135,10 @@ object SettingsReaderScreen : SearchableSettings { pref = readerPreferences.skipFiltered(), title = stringResource(R.string.pref_skip_filtered_chapters), ), + Preference.PreferenceItem.SwitchPreference( + pref = readerPreferences.skipDupe(), + title = stringResource(R.string.pref_skip_dupe_chapters), + ), Preference.PreferenceItem.SwitchPreference( pref = readerPreferences.alwaysShowChapterTransition(), title = stringResource(R.string.pref_always_show_chapter_transition), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index 8bbd042c0..d8c9c7896 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -183,6 +183,16 @@ class ReaderViewModel( } } else -> chapters + }.run { + if (readerPreferences.skipDupe().get()) { + groupBy { it.chapterNumber } + .mapValues { (_, chapters) -> + chapters.find { it.id == chapterId || it.scanlator == selectedChapter.scanlator } ?: chapters.first() + } + .values + } else { + this + } } chaptersForReader diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt index c9b577c17..a80295ddc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt @@ -60,6 +60,8 @@ class ReaderPreferences( fun skipFiltered() = preferenceStore.getBoolean("skip_filtered", true) + fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false) + // endregion // region Split two page spread diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index f9489a1eb..ef0f1dd5a 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -337,6 +337,7 @@ Keep screen on Skip chapters marked read Skip filtered chapters + Skip duplicate chapters Navigation Volume keys Invert volume keys