Retry a few times if library or updates crash
This commit is contained in:
parent
afab9c236d
commit
5abab75d26
@ -1,6 +1,8 @@
|
||||
package tachiyomi.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
|
||||
@ -17,6 +19,16 @@ 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 <--
|
||||
}
|
||||
|
||||
fun subscribe(read: Boolean, after: Long): Flow<List<UpdatesWithRelations>> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user