Fix page previews not going to the correct page

This commit is contained in:
Jobobby04 2022-12-18 12:49:59 -05:00
parent 33d5c08597
commit e294bd8bdb

View File

@ -86,6 +86,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.firstOrNull
@ -252,6 +253,9 @@ class ReaderViewModel(
state.map { it.viewerChapters?.currChapter } state.map { it.viewerChapters?.currChapter }
.distinctUntilChanged() .distinctUntilChanged()
.filterNotNull() .filterNotNull()
// SY -->
.drop(1) // allow the loader to set the first page and chapter id
// SY <-
.onEach { currentChapter -> .onEach { currentChapter ->
if (!currentChapter.chapter.read) { if (!currentChapter.chapter.read) {
currentChapter.requestedPage = currentChapter.chapter.last_page_read currentChapter.requestedPage = currentChapter.chapter.last_page_read