From 62f9071adcb9104329a25bcf19e004297d1a5d5e Mon Sep 17 00:00:00 2001 From: Eugene Date: Sat, 29 Jun 2019 16:27:58 -0400 Subject: [PATCH] Avoid infinite loading in global search if a single catalogue fails (#2097) --- .../ui/catalogue/global_search/CatalogueSearchPresenter.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchPresenter.kt index 39bcfc1c65..14312da130 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchPresenter.kt @@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.FilterList +import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.LoginSource import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter @@ -157,9 +158,9 @@ open class CatalogueSearchPresenter( fetchSourcesSubscription?.unsubscribe() fetchSourcesSubscription = Observable.from(sources) .flatMap({ source -> - source.fetchSearchManga(1, query, FilterList()) + Observable.defer { source.fetchSearchManga(1, query, FilterList()) } .subscribeOn(Schedulers.io()) - .onExceptionResumeNext(Observable.empty()) // Ignore timeouts. + .onErrorReturn { MangasPage(emptyList(), false) } // Ignore timeouts or other exceptions .map { it.mangas.take(10) } // Get at most 10 manga from search result. .map { it.map { networkToLocalManga(it, source.id) } } // Convert to local manga. .doOnNext { fetchImage(it, source) } // Load manga covers.