Attempt to fix crash when migrating or removing entries from library (mihonapp/mihon#1828)
Co-authored-by: Cuong-Tran <cuongtran.tm@gmail.com> Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> (cherry picked from commit 563bc02113a5ebc53650fdfdd13f408284a0cdc8)
This commit is contained in:
parent
870d77ed1f
commit
6e291c1510
4 changed files with 31 additions and 4 deletions
|
|
@ -38,6 +38,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
|||
- Fix backup/restore of category related preferences ([@cuong-tran](https://github.com/cuong-tran)) ([#1726](https://github.com/mihonapp/mihon/pull/1726))
|
||||
- Fix WebView sending app's package name in `X-Requested-With` header, which led to sources blocking access ([@AwkwardPeak7](https://github.com/AwkwardPeak7)) ([#1812](https://github.com/mihonapp/mihon/pull/1812))
|
||||
- Fix an issue where tracker reading progress is changed to a lower value ([@Animeboynz](https://github.com/Animeboynz)) ([#1795](https://github.com/mihonapp/mihon/pull/1795))
|
||||
- Attempt to fix crash when migrating or removing entries from library ([@FlaminSarge](https://github.com/FlaminSarge)) ([#1828](https://github.com/mihonapp/mihon/pull/1828))
|
||||
|
||||
### Removed
|
||||
- Remove alphabetical category sort option
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.retry
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class GetFavorites(
|
||||
private val mangaRepository: MangaRepository,
|
||||
|
|
@ -14,5 +20,17 @@ class GetFavorites(
|
|||
|
||||
fun subscribe(sourceId: Long): Flow<List<Manga>> {
|
||||
return mangaRepository.getFavoritesBySourceId(sourceId)
|
||||
// KMK -->
|
||||
.retry {
|
||||
if (it is NullPointerException) {
|
||||
delay(0.5.seconds)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}.catch {
|
||||
this@GetFavorites.logcat(LogPriority.ERROR, it)
|
||||
}
|
||||
// KMK <--
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ package tachiyomi.domain.manga.interactor
|
|||
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.retry
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.library.model.LibraryManga
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
|
@ -17,15 +20,15 @@ class GetLibraryManga(
|
|||
|
||||
fun subscribe(): Flow<List<LibraryManga>> {
|
||||
return mangaRepository.getLibraryMangaAsFlow()
|
||||
// SY -->
|
||||
.retry {
|
||||
if (it is NullPointerException) {
|
||||
delay(5.seconds)
|
||||
delay(0.5.seconds)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
// SY <--
|
||||
}.catch {
|
||||
this@GetLibraryManga.logcat(LogPriority.ERROR, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@ package tachiyomi.domain.updates.interactor
|
|||
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.retry
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.updates.model.UpdatesWithRelations
|
||||
import tachiyomi.domain.updates.repository.UpdatesRepository
|
||||
import java.time.Instant
|
||||
|
|
@ -41,11 +44,13 @@ class GetUpdates(
|
|||
// SY -->
|
||||
private fun <T> Flow<T>.catchNPE() = retry {
|
||||
if (it is NullPointerException) {
|
||||
delay(5.seconds)
|
||||
delay(0.5.seconds)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}.catch {
|
||||
this@GetUpdates.logcat(LogPriority.ERROR, it)
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue