Add concurrency to global search queries
This commit is contained in:
parent
82a08f24c0
commit
a7faf445c4
@ -118,15 +118,15 @@ class CatalogueSearchPresenter(
|
|||||||
|
|
||||||
fetchSourcesSubscription?.unsubscribe()
|
fetchSourcesSubscription?.unsubscribe()
|
||||||
fetchSourcesSubscription = Observable.from(sources)
|
fetchSourcesSubscription = Observable.from(sources)
|
||||||
.observeOn(Schedulers.io())
|
.flatMap({ source ->
|
||||||
.flatMap { source ->
|
|
||||||
source.fetchSearchManga(1, query, FilterList())
|
source.fetchSearchManga(1, query, FilterList())
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
.onExceptionResumeNext(Observable.empty()) // Ignore timeouts.
|
.onExceptionResumeNext(Observable.empty()) // Ignore timeouts.
|
||||||
.map { it.mangas.take(10) } // Get at most 10 manga from search result.
|
.map { it.mangas.take(10) } // Get at most 10 manga from search result.
|
||||||
.map { it.map { networkToLocalManga(it, source.id) } } // Convert to local manga.
|
.map { it.map { networkToLocalManga(it, source.id) } } // Convert to local manga.
|
||||||
.doOnNext { fetchImage(it, source) } // Load manga covers.
|
.doOnNext { fetchImage(it, source) } // Load manga covers.
|
||||||
.map { CatalogueSearchItem(source, it.map { CatalogueSearchCardItem(it) }) }
|
.map { CatalogueSearchItem(source, it.map { CatalogueSearchCardItem(it) }) }
|
||||||
}
|
}, 5)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
// Update matching source with the obtained results
|
// Update matching source with the obtained results
|
||||||
.map { result ->
|
.map { result ->
|
||||||
|
Loading…
Reference in New Issue
Block a user