mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-03 23:58:55 +01:00 
			
		
		
		
	Fix mark existing duplicate read chapters as read option not working in some cases (#1944)
This commit is contained in:
		@@ -15,7 +15,6 @@ import eu.kanade.domain.manga.model.readingMode
 | 
			
		||||
import eu.kanade.domain.source.interactor.GetIncognitoState
 | 
			
		||||
import eu.kanade.domain.track.interactor.TrackChapter
 | 
			
		||||
import eu.kanade.domain.track.service.TrackPreferences
 | 
			
		||||
import eu.kanade.tachiyomi.data.database.models.isRecognizedNumber
 | 
			
		||||
import eu.kanade.tachiyomi.data.database.models.toDomainChapter
 | 
			
		||||
import eu.kanade.tachiyomi.data.download.DownloadManager
 | 
			
		||||
import eu.kanade.tachiyomi.data.download.DownloadProvider
 | 
			
		||||
@@ -147,6 +146,11 @@ class ReaderViewModel @JvmOverloads constructor(
 | 
			
		||||
 | 
			
		||||
    private var chapterToDownload: Download? = null
 | 
			
		||||
 | 
			
		||||
    private val unfilteredChapterList by lazy {
 | 
			
		||||
        val manga = manga!!
 | 
			
		||||
        runBlocking { getChaptersByMangaId.await(manga.id, applyScanlatorFilter = false) }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Chapter list for the active manga. It's retrieved lazily and should be accessed for the first
 | 
			
		||||
     * time in a background thread to avoid blocking the UI.
 | 
			
		||||
@@ -559,15 +563,14 @@ class ReaderViewModel @JvmOverloads constructor(
 | 
			
		||||
            .contains(LibraryPreferences.MARK_DUPLICATE_CHAPTER_READ_EXISTING)
 | 
			
		||||
        if (!markDuplicateAsRead) return
 | 
			
		||||
 | 
			
		||||
        val duplicateUnreadChapters = chapterList
 | 
			
		||||
            .mapNotNull {
 | 
			
		||||
                val chapter = it.chapter
 | 
			
		||||
        val duplicateUnreadChapters = unfilteredChapterList
 | 
			
		||||
            .mapNotNull { chapter ->
 | 
			
		||||
                if (
 | 
			
		||||
                    !chapter.read &&
 | 
			
		||||
                    chapter.isRecognizedNumber &&
 | 
			
		||||
                    chapter.chapter_number == readerChapter.chapter.chapter_number
 | 
			
		||||
                    chapter.chapterNumber.toFloat() == readerChapter.chapter.chapter_number
 | 
			
		||||
                ) {
 | 
			
		||||
                    ChapterUpdate(id = chapter.id!!, read = true)
 | 
			
		||||
                    ChapterUpdate(id = chapter.id, read = true)
 | 
			
		||||
                } else {
 | 
			
		||||
                    null
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user