From 8901d02dba696fcbfcf24d7b5ecafdca34d05262 Mon Sep 17 00:00:00 2001 From: Claudio Riccio <75065419+Claudio2ooo@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:37:48 +0100 Subject: [PATCH] Update app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt Co-authored-by: Koitharu --- .../org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt index 4bc3f089e..a17c89fe3 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt @@ -258,9 +258,10 @@ class ReaderViewModel @Inject constructor( val prevJob = pageSaveJob pageSaveJob = launchLoadingJob(Dispatchers.Default) { prevJob?.cancelAndJoin() - val currentManga = checkNotNull(getCurrentManga()) { "Cannot find current manga" } - val currentChapter = checkNotNull(getCurrentChapter()) { "Cannot find current chapter" } - val currentPageNumber = checkNotNull(getPageNumber()) { "Cannot find current page number" } + val state = checkNotNull(getCurrentState()) + val currentManga = manga.requireValue() + val currentChapter = checkNotNull(currentManga.findChapter(state.chapterId)) + val currentPageNumber = state.page val currentPage = checkNotNull(getCurrentPage()) { "Cannot find current page" } val dest = pageSaveHelper.save(currentManga, currentChapter, currentPageNumber, setOf(currentPage)) onPageSaved.call(dest)