From 6cb255e60aa09644109eaa38065108f49dc05d3a Mon Sep 17 00:00:00 2001 From: nzoba <55888232+nzoba@users.noreply.github.com> Date: Sat, 14 May 2022 03:42:23 +0200 Subject: [PATCH] Add switch to DownloadPageLoader when chapter is downloaded (#7119) (cherry picked from commit 63627c81ebd6b3a9b1ee017f385a72b6fc8c8a49) --- .../eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index fb954bab7..946df975e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -22,6 +22,7 @@ import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.ui.reader.loader.ChapterLoader +import eu.kanade.tachiyomi.ui.reader.loader.HttpPageLoader import eu.kanade.tachiyomi.ui.reader.model.InsertPage import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage @@ -345,6 +346,14 @@ class ReaderPresenter( * that the user doesn't have to wait too long to continue reading. */ private fun preload(chapter: ReaderChapter) { + if (chapter.pageLoader is HttpPageLoader) { + val manga = manga ?: return + val isDownloaded = downloadManager.isChapterDownloaded(chapter.chapter, manga) + if (isDownloaded) { + chapter.state = ReaderChapter.State.Wait + } + } + if (chapter.state != ReaderChapter.State.Wait && chapter.state !is ReaderChapter.State.Error) { return }