From 01553b1ed8aaf01c96908356d7d384457d4227d9 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 15 Jul 2023 23:22:27 -0400 Subject: [PATCH] Don't update chapter progress if current page is errored Closes #5355 --- .../eu/kanade/tachiyomi/data/track/TrackService.kt | 2 +- .../eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt index 9bd87708f8..b1444b0670 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt @@ -145,7 +145,7 @@ abstract class TrackService(val id: Long) { } suspend fun setRemoteLastChapterRead(track: Track, chapterNumber: Int) { - if (track.last_chapter_read == 0F && track.last_chapter_read < chapterNumber && track.status != getRereadingStatus()) { + if (track.last_chapter_read == 0f && track.last_chapter_read < chapterNumber && track.status != getRereadingStatus()) { track.status = getReadingStatus() } track.last_chapter_read = chapterNumber.toFloat() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index 7970967383..1010c1fbe8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -402,7 +402,7 @@ class ReaderViewModel( // Save last page read and mark as read if needed viewModelScope.launchNonCancellable { - updateChapterProgress(selectedChapter, page.index) + updateChapterProgress(selectedChapter, page) } if (selectedChapter != getCurrentChapter()) { @@ -482,13 +482,15 @@ class ReaderViewModel( * Saves the chapter progress (last read page and whether it's read) * if incognito mode isn't on. */ - private suspend fun updateChapterProgress(readerChapter: ReaderChapter, pageIndex: Int) { + private suspend fun updateChapterProgress(readerChapter: ReaderChapter, page: Page) { + val pageIndex = page.index + mutableState.update { it.copy(currentPage = pageIndex + 1) } + readerChapter.requestedPage = pageIndex - if (!incognitoMode) { - readerChapter.requestedPage = pageIndex + if (!incognitoMode && page.status != Page.State.ERROR) { readerChapter.chapter.last_page_read = pageIndex if (readerChapter.pages?.lastIndex == pageIndex) { @@ -501,7 +503,6 @@ class ReaderViewModel( ChapterUpdate( id = readerChapter.chapter.id!!, read = readerChapter.chapter.read, - bookmark = readerChapter.chapter.bookmark, lastPageRead = readerChapter.chapter.last_page_read.toLong(), ), )