mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-02 07:08:55 +01:00
Seperate mark duplicate read chapters as read behaviors as options (#1870)
This commit is contained in:
@@ -71,6 +71,7 @@ import tachiyomi.domain.download.service.DownloadPreferences
|
||||
import tachiyomi.domain.history.interactor.GetNextChapters
|
||||
import tachiyomi.domain.history.interactor.UpsertHistory
|
||||
import tachiyomi.domain.history.model.HistoryUpdate
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.domain.manga.interactor.GetManga
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
@@ -101,6 +102,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
private val updateChapter: UpdateChapter = Injekt.get(),
|
||||
private val setMangaViewerFlags: SetMangaViewerFlags = Injekt.get(),
|
||||
private val getIncognitoState: GetIncognitoState = Injekt.get(),
|
||||
private val libraryPreferences: LibraryPreferences = Injekt.get(),
|
||||
) : ViewModel() {
|
||||
|
||||
private val mutableState = MutableStateFlow(State())
|
||||
@@ -535,24 +537,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
readerChapter.chapter.last_page_read = pageIndex
|
||||
|
||||
if (readerChapter.pages?.lastIndex == pageIndex) {
|
||||
readerChapter.chapter.read = true
|
||||
updateTrackChapterRead(readerChapter)
|
||||
deleteChapterIfNeeded(readerChapter)
|
||||
|
||||
val duplicateUnreadChapters = chapterList
|
||||
.mapNotNull {
|
||||
val chapter = it.chapter
|
||||
if (
|
||||
!chapter.read &&
|
||||
chapter.isRecognizedNumber &&
|
||||
chapter.chapter_number == readerChapter.chapter.chapter_number
|
||||
) {
|
||||
ChapterUpdate(id = chapter.id!!, read = true)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
updateChapter.awaitAll(duplicateUnreadChapters)
|
||||
updateChapterProgressOnComplete(readerChapter)
|
||||
}
|
||||
|
||||
updateChapter.await(
|
||||
@@ -565,6 +550,31 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun updateChapterProgressOnComplete(readerChapter: ReaderChapter) {
|
||||
readerChapter.chapter.read = true
|
||||
updateTrackChapterRead(readerChapter)
|
||||
deleteChapterIfNeeded(readerChapter)
|
||||
|
||||
val markDuplicateAsRead = libraryPreferences.markDuplicateReadChapterAsRead().get()
|
||||
.contains(LibraryPreferences.MARK_DUPLICATE_CHAPTER_READ_EXISTING)
|
||||
if (!markDuplicateAsRead) return
|
||||
|
||||
val duplicateUnreadChapters = chapterList
|
||||
.mapNotNull {
|
||||
val chapter = it.chapter
|
||||
if (
|
||||
!chapter.read &&
|
||||
chapter.isRecognizedNumber &&
|
||||
chapter.chapter_number == readerChapter.chapter.chapter_number
|
||||
) {
|
||||
ChapterUpdate(id = chapter.id!!, read = true)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
updateChapter.awaitAll(duplicateUnreadChapters)
|
||||
}
|
||||
|
||||
fun restartReadTimer() {
|
||||
chapterReadStartTime = Instant.now().toEpochMilli()
|
||||
}
|
||||
|
||||
@@ -137,8 +137,6 @@ class ReaderPreferences(
|
||||
|
||||
fun showNavigationOverlayOnStart() = preferenceStore.getBoolean("reader_navigation_overlay_on_start", false)
|
||||
|
||||
fun markDuplicateReadChapterAsRead() = preferenceStore.getBoolean("mark_duplicate_chapter_read", false)
|
||||
|
||||
// endregion
|
||||
|
||||
enum class FlashColor {
|
||||
|
||||
Reference in New Issue
Block a user