Always retry when its a NPE
This commit is contained in:
parent
f1bb886737
commit
3a5e23550f
@ -1,10 +1,11 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.retry
|
||||
import tachiyomi.domain.library.model.LibraryManga
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class GetLibraryManga(
|
||||
private val mangaRepository: MangaRepository,
|
||||
@ -17,12 +18,12 @@ class GetLibraryManga(
|
||||
fun subscribe(): Flow<List<LibraryManga>> {
|
||||
return mangaRepository.getLibraryMangaAsFlow()
|
||||
// SY -->
|
||||
.let {
|
||||
var retries = 0
|
||||
it.retry {
|
||||
(retries++ < 3) && it is NullPointerException
|
||||
}.onEach {
|
||||
retries = 0
|
||||
.retry {
|
||||
if (it is NullPointerException) {
|
||||
delay(5.seconds)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
// SY <--
|
||||
|
@ -1,11 +1,12 @@
|
||||
package tachiyomi.domain.updates.interactor
|
||||
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.retry
|
||||
import tachiyomi.domain.updates.model.UpdatesWithRelations
|
||||
import tachiyomi.domain.updates.repository.UpdatesRepository
|
||||
import java.util.Calendar
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class GetUpdates(
|
||||
private val repository: UpdatesRepository,
|
||||
@ -20,12 +21,12 @@ class GetUpdates(
|
||||
fun subscribe(after: Long): Flow<List<UpdatesWithRelations>> {
|
||||
return repository.subscribeAll(after)
|
||||
// SY -->
|
||||
.let {
|
||||
var retries = 0
|
||||
it.retry {
|
||||
(retries++ < 3) && it is NullPointerException
|
||||
}.onEach {
|
||||
retries = 0
|
||||
.retry {
|
||||
if (it is NullPointerException) {
|
||||
delay(5.seconds)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
// SY <--
|
||||
|
Loading…
x
Reference in New Issue
Block a user