Save current page state on configuration change
Fixes #8881 The actual issue is that the ViewModel migration actually differs between what the current `init` block and previous `onSave` methods did; where the `init` block does not get triggered on saving the instance on config changes. Not entirely sure why onSaveInstanceState was explicitly avoided for config changes before, but we just do it all the time now and end up updating the requestedPage with the current page. (cherry picked from commit 2ebc8d9ae51f84b0f69dee603a5448a72013f734) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
This commit is contained in:
parent
a53190f7c4
commit
4ee66f6185
@ -358,9 +358,7 @@ class ReaderActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
if (!isChangingConfigurations) {
|
viewModel.onSaveInstanceState()
|
||||||
viewModel.onSaveInstanceStateNonConfigurationChange()
|
|
||||||
}
|
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,10 +274,10 @@ class ReaderViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the activity is saved and not changing configurations. It updates the database
|
* Called when the activity is saved. It updates the database
|
||||||
* to persist the current progress of the active chapter.
|
* to persist the current progress of the active chapter.
|
||||||
*/
|
*/
|
||||||
fun onSaveInstanceStateNonConfigurationChange() {
|
fun onSaveInstanceState() {
|
||||||
val currentChapter = getCurrentChapter() ?: return
|
val currentChapter = getCurrentChapter() ?: return
|
||||||
viewModelScope.launchNonCancellable {
|
viewModelScope.launchNonCancellable {
|
||||||
saveChapterProgress(currentChapter)
|
saveChapterProgress(currentChapter)
|
||||||
@ -612,6 +612,7 @@ class ReaderViewModel(
|
|||||||
private suspend fun saveChapterProgress(readerChapter: ReaderChapter) {
|
private suspend fun saveChapterProgress(readerChapter: ReaderChapter) {
|
||||||
if (!incognitoMode || hasTrackers) {
|
if (!incognitoMode || hasTrackers) {
|
||||||
val chapter = readerChapter.chapter
|
val chapter = readerChapter.chapter
|
||||||
|
getCurrentChapter()?.requestedPage = chapter.last_page_read
|
||||||
updateChapter.await(
|
updateChapter.await(
|
||||||
ChapterUpdate(
|
ChapterUpdate(
|
||||||
id = chapter.id!!,
|
id = chapter.id!!,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user