Skip to content

Commit

Permalink
Exit track progress update early in case new chapter is same as curre…
Browse files Browse the repository at this point in the history
…nt local (#937)

Prevents unnecessary requests
  • Loading branch information
schroda authored Apr 28, 2024
1 parent fbf726c commit 72b1b5b
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,22 @@ object Track {
records.forEach {
val tracker = TrackerManager.getTracker(it[TrackRecordTable.trackerId]) ?: return@forEach

val localLastReadChapter = it[TrackRecordTable.lastChapterRead]

val log = KotlinLogging.logger { "${logger.name}::trackChapter(mangaId= $mangaId, chapterNumber= $chapterNumber)" }

if (localLastReadChapter == chapterNumber) {
log.debug { "new chapter is the same as the local last read chapter" }
return@forEach
}

val track = it.toTrack()
tracker.refresh(track)
upsertTrackRecord(track)

val lastChapterRead = track.last_chapter_read

logger.debug {
"trackChapter(mangaId= $mangaId, chapterNumber= $chapterNumber): tracker= $tracker, remoteLastReadChapter= $lastChapterRead"
}
log.debug { "tracker= $tracker, remoteLastReadChapter= $lastChapterRead" }

if (tracker.isLoggedIn && chapterNumber > lastChapterRead) {
track.last_chapter_read = chapterNumber.toFloat()
Expand Down

0 comments on commit 72b1b5b

Please sign in to comment.