Retain remote last chapter read if it's higher than the local one for EnhancedTracker (mihonapp/mihon#1301)

(cherry picked from commit 44aab7a2437ffdab354ee5ed82593fbaabb06a64)
This commit is contained in:
brewkunz 2024-10-10 14:15:06 +02:00 committed by Cuong-Tran
parent e7d4065c2a
commit 774f99e0b6
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -12,6 +12,7 @@ import tachiyomi.domain.track.interactor.InsertTrack
import tachiyomi.domain.track.model.Track
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import kotlin.math.max
class SyncChapterProgressWithTrack(
private val updateChapter: UpdateChapter,
@ -59,7 +60,8 @@ class SyncChapterProgressWithTrack(
// only take into account continuous reading
val localLastRead = sortedChapters.takeWhile { it.read }.lastOrNull()?.chapterNumber ?: 0F
// Tracker will update to latest read chapter
val updatedTrack = remoteTrack.copy(lastChapterRead = localLastRead.toDouble())
val lastRead = max(remoteTrack.lastChapterRead, localLastRead.toDouble())
val updatedTrack = remoteTrack.copy(lastChapterRead = lastRead)
try {
// Update Tracker to localLastRead if needed