Retry a few times if library or updates crash
(cherry picked from commit 5abab75d26)
This commit is contained in:
parent
428fa17bfc
commit
37a4e2d72d
2 changed files with 24 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package eu.kanade.domain.manga.interactor
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -14,5 +16,15 @@ 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
|
||||
}
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package tachiyomi.domain.updates.interactor
|
||||
|
||||
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
|
||||
|
|
@ -13,5 +15,15 @@ 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
|
||||
}
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue