Always retry when its a NPE

This commit is contained in:
Jobobby04 2023-05-06 18:58:06 -04:00
parent f1bb886737
commit 3a5e23550f
2 changed files with 16 additions and 14 deletions

View File

@ -1,10 +1,11 @@
package tachiyomi.domain.manga.interactor package tachiyomi.domain.manga.interactor
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.retry import kotlinx.coroutines.flow.retry
import tachiyomi.domain.library.model.LibraryManga import tachiyomi.domain.library.model.LibraryManga
import tachiyomi.domain.manga.repository.MangaRepository import tachiyomi.domain.manga.repository.MangaRepository
import kotlin.time.Duration.Companion.seconds
class GetLibraryManga( class GetLibraryManga(
private val mangaRepository: MangaRepository, private val mangaRepository: MangaRepository,
@ -17,12 +18,12 @@ class GetLibraryManga(
fun subscribe(): Flow<List<LibraryManga>> { fun subscribe(): Flow<List<LibraryManga>> {
return mangaRepository.getLibraryMangaAsFlow() return mangaRepository.getLibraryMangaAsFlow()
// SY --> // SY -->
.let { .retry {
var retries = 0 if (it is NullPointerException) {
it.retry { delay(5.seconds)
(retries++ < 3) && it is NullPointerException true
}.onEach { } else {
retries = 0 false
} }
} }
// SY <-- // SY <--

View File

@ -1,11 +1,12 @@
package tachiyomi.domain.updates.interactor package tachiyomi.domain.updates.interactor
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.retry import kotlinx.coroutines.flow.retry
import tachiyomi.domain.updates.model.UpdatesWithRelations import tachiyomi.domain.updates.model.UpdatesWithRelations
import tachiyomi.domain.updates.repository.UpdatesRepository import tachiyomi.domain.updates.repository.UpdatesRepository
import java.util.Calendar import java.util.Calendar
import kotlin.time.Duration.Companion.seconds
class GetUpdates( class GetUpdates(
private val repository: UpdatesRepository, private val repository: UpdatesRepository,
@ -20,12 +21,12 @@ class GetUpdates(
fun subscribe(after: Long): Flow<List<UpdatesWithRelations>> { fun subscribe(after: Long): Flow<List<UpdatesWithRelations>> {
return repository.subscribeAll(after) return repository.subscribeAll(after)
// SY --> // SY -->
.let { .retry {
var retries = 0 if (it is NullPointerException) {
it.retry { delay(5.seconds)
(retries++ < 3) && it is NullPointerException true
}.onEach { } else {
retries = 0 false
} }
} }
// SY <-- // SY <--