diff --git a/app/src/main/java/eu/kanade/domain/track/anime/interactor/SyncEpisodeProgressWithTrack.kt b/app/src/main/java/eu/kanade/domain/track/anime/interactor/SyncEpisodeProgressWithTrack.kt index cf2c56aee..f30832bdb 100644 --- a/app/src/main/java/eu/kanade/domain/track/anime/interactor/SyncEpisodeProgressWithTrack.kt +++ b/app/src/main/java/eu/kanade/domain/track/anime/interactor/SyncEpisodeProgressWithTrack.kt @@ -10,6 +10,7 @@ import tachiyomi.domain.items.episode.interactor.UpdateEpisode import tachiyomi.domain.items.episode.model.toEpisodeUpdate import tachiyomi.domain.track.anime.interactor.InsertAnimeTrack import tachiyomi.domain.track.anime.model.AnimeTrack +import kotlin.math.max class SyncEpisodeProgressWithTrack( private val updateEpisode: UpdateEpisode, @@ -36,7 +37,8 @@ class SyncEpisodeProgressWithTrack( // only take into account continuous watching val localLastSeen = sortedEpisodes.takeWhile { it.seen }.lastOrNull()?.episodeNumber ?: 0F - val updatedTrack = remoteTrack.copy(lastEpisodeSeen = localLastSeen.toDouble()) + val lastSeen = max(remoteTrack.lastEpisodeSeen, localLastSeen.toDouble()) + val updatedTrack = remoteTrack.copy(lastEpisodeSeen = lastSeen) try { service.update(updatedTrack.toDbTrack()) diff --git a/app/src/main/java/eu/kanade/domain/track/manga/interactor/SyncChapterProgressWithTrack.kt b/app/src/main/java/eu/kanade/domain/track/manga/interactor/SyncChapterProgressWithTrack.kt index ab36ce46f..2ce23160d 100644 --- a/app/src/main/java/eu/kanade/domain/track/manga/interactor/SyncChapterProgressWithTrack.kt +++ b/app/src/main/java/eu/kanade/domain/track/manga/interactor/SyncChapterProgressWithTrack.kt @@ -10,6 +10,7 @@ import tachiyomi.domain.items.chapter.interactor.UpdateChapter import tachiyomi.domain.items.chapter.model.toChapterUpdate import tachiyomi.domain.track.manga.interactor.InsertMangaTrack import tachiyomi.domain.track.manga.model.MangaTrack +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())