From 90db3acefd6290310c8cf8bab2563b3413a8cf4a Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 14 Dec 2022 23:04:30 -0500 Subject: [PATCH] Don't start at last read page if chapter is completely marked as read Fixes #8737 --- .../java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 feddc0711..b972b84b7 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 @@ -67,6 +67,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.launchIn @@ -212,11 +213,12 @@ class ReaderViewModel( // To save state state.map { it.viewerChapters?.currChapter } .distinctUntilChanged() + .filterNotNull() .onEach { currentChapter -> - if (currentChapter != null) { + if (!currentChapter.chapter.read) { currentChapter.requestedPage = currentChapter.chapter.last_page_read - chapterId = currentChapter.chapter.id!! } + chapterId = currentChapter.chapter.id!! } .launchIn(viewModelScope) }