|
@@ -201,17 +201,6 @@ class ReaderViewModel(
|
|
|
|
|
|
private val incognitoMode = preferences.incognitoMode().get()
|
|
|
|
|
|
- override fun onCleared() {
|
|
|
- val currentChapters = state.value.viewerChapters
|
|
|
- if (currentChapters != null) {
|
|
|
- currentChapters.unref()
|
|
|
- saveReadingProgress(currentChapters.currChapter)
|
|
|
- chapterToDownload?.let {
|
|
|
- downloadManager.addDownloadsToStartOfQueue(listOf(it))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
init {
|
|
|
// To save state
|
|
|
state.map { it.viewerChapters?.currChapter }
|
|
@@ -226,6 +215,17 @@ class ReaderViewModel(
|
|
|
.launchIn(viewModelScope)
|
|
|
}
|
|
|
|
|
|
+ override fun onCleared() {
|
|
|
+ val currentChapters = state.value.viewerChapters
|
|
|
+ if (currentChapters != null) {
|
|
|
+ currentChapters.unref()
|
|
|
+ saveReadingProgress(currentChapters.currChapter)
|
|
|
+ chapterToDownload?.let {
|
|
|
+ downloadManager.addDownloadsToStartOfQueue(listOf(it))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Called when the user pressed the back button and is going to leave the reader. Used to
|
|
|
* trigger deletion of the downloaded chapters.
|
|
@@ -338,10 +338,11 @@ class ReaderViewModel(
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Called when the user is going to load the prev/next chapter through the menu button.
|
|
|
+ * Called when the user is going to load the prev/next chapter through the toolbar buttons.
|
|
|
*/
|
|
|
private suspend fun loadAdjacent(chapter: ReaderChapter) {
|
|
|
val loader = loader ?: return
|
|
|
+ saveCurrentChapterReadingProgress()
|
|
|
|
|
|
logcat { "Loading adjacent ${chapter.chapter.url}" }
|
|
|
|