Skip to content

Commit

Permalink
add mark read dupes on reading (#1079)
Browse files Browse the repository at this point in the history
* Feature: mark read dupes

* dupe chapter reading add summary

* Update ReaderViewModel.kt

* Update i18n/src/commonMain/resources/MR/base/strings.xml

* Update app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt

---------

Co-authored-by: jobobby04 <jobobby04@users.noreply.github.com>
  • Loading branch information
Riztard and jobobby04 authored Mar 2, 2024
1 parent d8082de commit 6f3f109
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ object SettingsReaderScreen : SearchableSettings {
pref = readerPreferences.skipDupe(),
title = stringResource(MR.strings.pref_skip_dupe_chapters),
),
Preference.PreferenceItem.SwitchPreference(
pref = readerPreferences.markReadDupe(),
title = stringResource(MR.strings.pref_mark_read_dupe_chapters),
subtitle = stringResource(MR.strings.pref_mark_read_dupe_chapters_summary),
),
Preference.PreferenceItem.SwitchPreference(
pref = readerPreferences.alwaysShowChapterTransition(),
title = stringResource(MR.strings.pref_always_show_chapter_transition),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import eu.kanade.domain.base.BasePreferences
import eu.kanade.domain.chapter.interactor.SetReadStatus
import eu.kanade.domain.chapter.model.toDbChapter
import eu.kanade.domain.manga.interactor.SetMangaViewerFlags
import eu.kanade.domain.manga.model.readerOrientation
Expand Down Expand Up @@ -129,6 +130,7 @@ class ReaderViewModel @JvmOverloads constructor(
private val getMergedMangaById: GetMergedMangaById = Injekt.get(),
private val getMergedReferencesById: GetMergedReferencesById = Injekt.get(),
private val getMergedChaptersByMangaId: GetMergedChaptersByMangaId = Injekt.get(),
private val setReadStatus: SetReadStatus = Injekt.get()
// SY <--
) : ViewModel() {

Expand Down Expand Up @@ -691,6 +693,13 @@ class ReaderViewModel @JvmOverloads constructor(
// SY <--
readerChapter.chapter.read = true
// SY -->
if (readerPreferences.markReadDupe().get()) {
getChaptersByMangaId.await(manga!!.id).sortedByDescending { it.sourceOrder }
.filter {
!it.read && it.chapterNumber > 0.0 && it.chapterNumber.toFloat() == readerChapter.chapter.chapter_number
}
.also { setReadStatus.await(true, *it.toTypedArray()) }
}
if (manga?.isEhBasedManga() == true) {
viewModelScope.launchNonCancellable {
val chapterUpdates = chapterList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class ReaderPreferences(

fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false)

fun markReadDupe() = preferenceStore.getBoolean("mark_read_dupe", false)

// endregion

// region Split two page spread
Expand Down
2 changes: 2 additions & 0 deletions i18n/src/commonMain/resources/MR/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@
<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_dupe_chapters">Skip duplicate chapters</string>
<string name="pref_mark_read_dupe_chapters">Mark duplicate chapters as read</string>
<string name="pref_mark_read_dupe_chapters_summary">Mark duplicate chapters as read after reading</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_inverted">Invert volume keys</string>
Expand Down

0 comments on commit 6f3f109

Please sign in to comment.