Skip to content

Commit

Permalink
Ignore chapters with 0 or under chapter numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jobobby04 committed Feb 18, 2024
1 parent 2daccb5 commit d8082de
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.notification.Notifications
import eu.kanade.tachiyomi.data.track.TrackStatus
import eu.kanade.tachiyomi.data.track.TrackerManager
import eu.kanade.tachiyomi.source.UnmeteredSource
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.model.UpdateStrategy
import eu.kanade.tachiyomi.source.online.all.MergedSource
Expand Down Expand Up @@ -64,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
Expand Down Expand Up @@ -101,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) {
Expand Down Expand Up @@ -400,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 {
Expand Down

0 comments on commit d8082de

Please sign in to comment.