feature: automatically mark new duplicate read chapters as read
This commit is contained in:
parent
cf777d9893
commit
526325c001
4 changed files with 22 additions and 1 deletions
|
@ -269,6 +269,11 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||
pref = libraryPreferences.newShowUpdatesCount(),
|
||||
title = stringResource(R.string.pref_library_update_show_tab_badge),
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = libraryPreferences.libraryReadDuplicateChapters(),
|
||||
title = stringResource(R.string.pref_library_mark_duplicate_chapters),
|
||||
subtitle = stringResource(R.string.pref_library_mark_duplicate_chapters_summary),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import androidx.work.WorkInfo
|
|||
import androidx.work.WorkQuery
|
||||
import androidx.work.WorkerParameters
|
||||
import androidx.work.workDataOf
|
||||
import eu.kanade.domain.chapter.interactor.SetReadStatus
|
||||
import eu.kanade.domain.chapter.interactor.SyncChaptersWithSource
|
||||
import eu.kanade.domain.chapter.interactor.SyncChaptersWithTrackServiceTwoWay
|
||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
||||
|
@ -101,6 +102,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||
private val getTracks: GetTracks = Injekt.get()
|
||||
private val insertTrack: InsertTrack = Injekt.get()
|
||||
private val syncChaptersWithTrackServiceTwoWay: SyncChaptersWithTrackServiceTwoWay = Injekt.get()
|
||||
private val setReadStatus: SetReadStatus = Injekt.get()
|
||||
|
||||
private val notifier = LibraryUpdateNotifier(context)
|
||||
|
||||
|
@ -262,7 +264,17 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||
else -> {
|
||||
try {
|
||||
val newChapters = updateManga(manga)
|
||||
.sortedByDescending { it.sourceOrder }
|
||||
.sortedByDescending { it.sourceOrder }.run {
|
||||
if (libraryPreferences.libraryReadDuplicateChapters().get()) {
|
||||
val readChapters = getChapterByMangaId.await(manga.id).filter { it.read }
|
||||
val newReadChapters = this.filter { chapter -> readChapters.any { it.chapterNumber == chapter.chapterNumber } }
|
||||
.also { setReadStatus.await(true, *it.toTypedArray()) }
|
||||
|
||||
this.filterNot { newReadChapters.contains(it) }
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
if (newChapters.isNotEmpty()) {
|
||||
val categoryIds = getCategories.await(manga.id).map { it.id }
|
||||
|
|
|
@ -38,6 +38,8 @@ class LibraryPreferences(
|
|||
),
|
||||
)
|
||||
|
||||
fun libraryReadDuplicateChapters() = preferenceStore.getBoolean("pref_library_mark_duplicate_chapters", false)
|
||||
|
||||
fun leadingExpectedDays() = preferenceStore.getInt("pref_library_before_expect_key", 1)
|
||||
fun followingExpectedDays() = preferenceStore.getInt("pref_library_after_expect_key", 1)
|
||||
|
||||
|
|
|
@ -277,6 +277,8 @@
|
|||
<string name="pref_library_update_refresh_metadata_summary">Check for new cover and details when updating library</string>
|
||||
<string name="pref_library_update_refresh_trackers">Automatically refresh trackers</string>
|
||||
<string name="pref_library_update_refresh_trackers_summary">Update trackers when updating library</string>
|
||||
<string name="pref_library_mark_duplicate_chapters">Mark new duplicate chapters as read</string>
|
||||
<string name="pref_library_mark_duplicate_chapters_summary">Automatically mark new chapters as read if it has been read before</string>
|
||||
|
||||
<string name="default_category">Default category</string>
|
||||
<string name="default_category_summary">Always ask</string>
|
||||
|
|
Reference in a new issue