Add Reader Setting to Skip Dupe Chapters (#8831)

Add reader setting to filter dupe chapters with same scanlator priority.
This commit is contained in:
MCAxiaz 2023-01-08 12:40:23 -08:00 committed by GitHub
parent e265b929a1
commit cf393b217b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 0 deletions

View File

@ -135,6 +135,10 @@ object SettingsReaderScreen : SearchableSettings {
pref = readerPreferences.skipFiltered(), pref = readerPreferences.skipFiltered(),
title = stringResource(R.string.pref_skip_filtered_chapters), 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( Preference.PreferenceItem.SwitchPreference(
pref = readerPreferences.alwaysShowChapterTransition(), pref = readerPreferences.alwaysShowChapterTransition(),
title = stringResource(R.string.pref_always_show_chapter_transition), title = stringResource(R.string.pref_always_show_chapter_transition),

View File

@ -183,6 +183,16 @@ class ReaderViewModel(
} }
} }
else -> chapters 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 chaptersForReader

View File

@ -60,6 +60,8 @@ class ReaderPreferences(
fun skipFiltered() = preferenceStore.getBoolean("skip_filtered", true) fun skipFiltered() = preferenceStore.getBoolean("skip_filtered", true)
fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false)
// endregion // endregion
// region Split two page spread // region Split two page spread

View File

@ -337,6 +337,7 @@
<string name="pref_keep_screen_on">Keep screen on</string> <string name="pref_keep_screen_on">Keep screen on</string>
<string name="pref_skip_read_chapters">Skip chapters marked read</string> <string name="pref_skip_read_chapters">Skip chapters marked read</string>
<string name="pref_skip_filtered_chapters">Skip filtered chapters</string> <string name="pref_skip_filtered_chapters">Skip filtered chapters</string>
<string name="pref_skip_dupe_chapters">Skip duplicate chapters</string>
<string name="pref_reader_navigation">Navigation</string> <string name="pref_reader_navigation">Navigation</string>
<string name="pref_read_with_volume_keys">Volume keys</string> <string name="pref_read_with_volume_keys">Volume keys</string>
<string name="pref_read_with_volume_keys_inverted">Invert volume keys</string> <string name="pref_read_with_volume_keys_inverted">Invert volume keys</string>