Ignore chapters with 0 or under chapter numbers

This commit is contained in:
Jobobby04 2024-02-18 11:47:19 -05:00 committed by Cuong M. Tran
parent f6c1239609
commit b70257bd3b
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -63,6 +63,7 @@ import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.UnsortedPreferences
import tachiyomi.domain.category.interactor.GetCategories
import tachiyomi.domain.category.model.Category
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.chapter.model.NoChaptersException
import tachiyomi.domain.download.service.DownloadPreferences
@ -100,7 +101,6 @@ import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicInteger
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
class LibraryUpdateJob(private val context: Context, workerParams: WorkerParameters) :
CoroutineWorker(context, workerParams) {
@ -399,8 +399,12 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
.sortedByDescending { it.sourceOrder }.run {
if (libraryPreferences.libraryReadDuplicateChapters().get()) {
val readChapters = getChaptersByMangaId.await(manga.id).filter { it.read }
val newReadChapters = this.filter { chapter -> readChapters.any { it.chapterNumber == chapter.chapterNumber } }
.also { setReadStatus.await(true, *it.toTypedArray()) }
val newReadChapters = this.filter { chapter ->
chapter.chapterNumber > 0 &&
readChapters.any { it.chapterNumber == chapter.chapterNumber }
}
setReadStatus.await(true, *newReadChapters.toTypedArray())
this.filterNot { newReadChapters.contains(it) }
} else {