Skip to content

Commit

Permalink
fix[tracking]: Fix last chapter read
Browse files Browse the repository at this point in the history
  • Loading branch information
brewkunz committed Oct 7, 2024
1 parent 9ea2344 commit 38376e0
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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())
Expand Down

0 comments on commit 38376e0

Please sign in to comment.