fix: Fix mark existing duplicate read chapters as read option not working in some cases

This commit is contained in:
AntsyLich 2025-05-28 09:05:14 +07:00 committed by Ahmad Ansori Palembani
parent 7964ac87c6
commit 18528fbd92
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -67,6 +67,7 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
@ -156,6 +157,11 @@ class ReaderViewModel(
private var finished = false
private var chapterToDownload: Download? = null
private val unfilteredChapterList by lazy {
val manga = manga!!
runBlocking { getChapter.awaitAll(manga, filterScanlators = false) }
}
private lateinit var chapterList: List<ReaderChapter>
private var chapterItems = emptyList<ReaderChapterItem>()
@ -639,9 +645,8 @@ class ReaderViewModel(
.contains(LibraryPreferences.MARK_DUPLICATE_READ_CHAPTER_READ_EXISTING)
if (!markDuplicateAsRead) return
val duplicateUnreadChapters = chapterList
.mapNotNull {
val chapter = it.chapter
val duplicateUnreadChapters = unfilteredChapterList
.mapNotNull { chapter ->
if (
!chapter.read &&
chapter.isRecognizedNumber &&