mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-26 06:43:45 +03:00
Retain remote last chapter read if it's higher than the local one for EnhancedTracker
Co-authored-by: brewkunz <102181083+brewkunz@users.noreply.github.com>
This commit is contained in:
parent
17b5341851
commit
94d67bf930
2 changed files with 6 additions and 2 deletions
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue