mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 19:51:50 +01:00
Jumping to a new chapter in reader now saves progress
and jumping back goes back to the last page you were on
This commit is contained in:
parent
bb422743dd
commit
f438933fc3
@ -288,14 +288,17 @@ class ReaderPresenter(
|
||||
fun loadChapter(chapter: Chapter) {
|
||||
val loader = loader ?: return
|
||||
|
||||
Timber.d("Loading adjacent ${chapter.url}")
|
||||
viewerChaptersRelay.value?.currChapter?.let(::onChapterChanged)
|
||||
|
||||
Timber.d("Loading ${chapter.url}")
|
||||
|
||||
activeChapterSubscription?.unsubscribe()
|
||||
activeChapterSubscription = getLoadObservable(loader, ReaderChapter(chapter))
|
||||
.doOnSubscribe { isLoadingAdjacentChapterRelay.call(true) }
|
||||
.doOnUnsubscribe { isLoadingAdjacentChapterRelay.call(false) }
|
||||
.subscribeFirst({ view, _ ->
|
||||
view.moveToPageIndex(0)
|
||||
val lastPage = if (chapter.pages_left <= 1) 0 else chapter.last_page_read
|
||||
view.moveToPageIndex(lastPage)
|
||||
view.refreshChapters()
|
||||
}, { _, _ ->
|
||||
// Ignore onError event, viewers handle that state
|
||||
@ -351,7 +354,7 @@ class ReaderPresenter(
|
||||
|
||||
if (selectedChapter != currentChapters.currChapter) {
|
||||
Timber.d("Setting ${selectedChapter.chapter.url} as active")
|
||||
onChapterChanged(currentChapters.currChapter, selectedChapter)
|
||||
onChapterChanged(currentChapters.currChapter)
|
||||
loadNewChapter(selectedChapter)
|
||||
return true
|
||||
}
|
||||
@ -362,7 +365,7 @@ class ReaderPresenter(
|
||||
* Called when a chapter changed from [fromChapter] to [toChapter]. It updates [fromChapter]
|
||||
* on the database.
|
||||
*/
|
||||
private fun onChapterChanged(fromChapter: ReaderChapter, toChapter: ReaderChapter) {
|
||||
private fun onChapterChanged(fromChapter: ReaderChapter) {
|
||||
saveChapterProgress(fromChapter)
|
||||
saveChapterHistory(fromChapter)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user