Fix latest + browse page crash when source returns null
This commit is contained in:
parent
f20e5d864d
commit
86defec57c
@ -16,10 +16,12 @@ import eu.kanade.tachiyomi.source.model.SManga
|
|||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourcePresenter.Companion.toItems
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourcePresenter.Companion.toItems
|
||||||
import exh.EXHSavedSearch
|
import exh.EXHSavedSearch
|
||||||
|
import exh.util.asFlow
|
||||||
import java.lang.RuntimeException
|
import java.lang.RuntimeException
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.flow.singleOrNull
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
@ -105,12 +107,17 @@ open class IndexPresenter(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (source.supportsLatest) {
|
if (source.supportsLatest) {
|
||||||
val results = source.fetchLatestUpdates(1)
|
val results = try {
|
||||||
.toBlocking()
|
source.fetchLatestUpdates(1)
|
||||||
.single()
|
.asFlow()
|
||||||
.mangas
|
.singleOrNull()
|
||||||
.take(10)
|
?.mangas
|
||||||
.map { networkToLocalManga(it, source.id) }
|
?.take(10)
|
||||||
|
?.map { networkToLocalManga(it, source.id) }
|
||||||
|
?: emptyList()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
fetchImage(results, true)
|
fetchImage(results, true)
|
||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
@ -128,12 +135,17 @@ open class IndexPresenter(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
val results = source.fetchPopularManga(1)
|
val results = try {
|
||||||
.toBlocking()
|
source.fetchPopularManga(1)
|
||||||
.single()
|
.asFlow()
|
||||||
.mangas
|
.singleOrNull()
|
||||||
.take(10)
|
?.mangas
|
||||||
.map { networkToLocalManga(it, source.id) }
|
?.take(10)
|
||||||
|
?.map { networkToLocalManga(it, source.id) }
|
||||||
|
?: emptyList()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
fetchImage(results, false)
|
fetchImage(results, false)
|
||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user