From 44aab7a2437ffdab354ee5ed82593fbaabb06a64 Mon Sep 17 00:00:00 2001 From: brewkunz <102181083+brewkunz@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:15:06 +0200 Subject: [PATCH] Retain remote last chapter read if it's higher than the local one for EnhancedTracker (#1301) --- .../domain/track/interactor/SyncChapterProgressWithTrack.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/domain/track/interactor/SyncChapterProgressWithTrack.kt b/app/src/main/java/eu/kanade/domain/track/interactor/SyncChapterProgressWithTrack.kt index 8e6df2289..0c9564091 100644 --- a/app/src/main/java/eu/kanade/domain/track/interactor/SyncChapterProgressWithTrack.kt +++ b/app/src/main/java/eu/kanade/domain/track/interactor/SyncChapterProgressWithTrack.kt @@ -10,6 +10,7 @@ import tachiyomi.domain.chapter.interactor.UpdateChapter import tachiyomi.domain.chapter.model.toChapterUpdate import tachiyomi.domain.track.interactor.InsertTrack import tachiyomi.domain.track.model.Track +import kotlin.math.max class SyncChapterProgressWithTrack( private val updateChapter: UpdateChapter, @@ -36,7 +37,8 @@ class SyncChapterProgressWithTrack( // only take into account continuous reading val localLastRead = sortedChapters.takeWhile { it.read }.lastOrNull()?.chapterNumber ?: 0F - val updatedTrack = remoteTrack.copy(lastChapterRead = localLastRead.toDouble()) + val lastRead = max(remoteTrack.lastChapterRead, localLastRead.toDouble()) + val updatedTrack = remoteTrack.copy(lastChapterRead = lastRead) try { tracker.update(updatedTrack.toDbTrack())