From cd867f800ef95afcf5f3f9eef17ad305aaed7793 Mon Sep 17 00:00:00 2001 From: morcefaster <51055657+morcefaster@users.noreply.github.com> Date: Mon, 16 Mar 2020 18:20:35 +0200 Subject: [PATCH] Fix for perpetually loading chapters (#2718) * Fix for perpetually loading chapters * Removed page count check --- .../kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt index 77a7b24a9f..be03beb16a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt @@ -26,7 +26,7 @@ class ChapterLoader( * completes if the chapter is already loaded. */ fun loadChapter(chapter: ReaderChapter): Completable { - if (chapter.state is ReaderChapter.State.Loaded) { + if (chapterIsReady(chapter)) { return Completable.complete() } @@ -61,6 +61,13 @@ class ChapterLoader( .doOnError { chapter.state = ReaderChapter.State.Error(it) } } + /** + * Checks [chapter] to be loaded based on present pages and loader in addition to state. + */ + private fun chapterIsReady(chapter: ReaderChapter): Boolean { + return chapter.state is ReaderChapter.State.Loaded && chapter.pageLoader != null + } + /** * Returns the page loader to use for this [chapter]. */