Fix crash: add error handling for scrobbling info
This commit is contained in:
@@ -140,6 +140,7 @@ class DetailsViewModel @Inject constructor(
|
|||||||
get() = scrobblers.any { it.isEnabled }
|
get() = scrobblers.any { it.isEnabled }
|
||||||
|
|
||||||
val scrobblingInfo: StateFlow<List<ScrobblingInfo>> = interactor.observeScrobblingInfo(mangaId)
|
val scrobblingInfo: StateFlow<List<ScrobblingInfo>> = interactor.observeScrobblingInfo(mangaId)
|
||||||
|
.withErrorHandling()
|
||||||
.stateIn(viewModelScope + Dispatchers.Default, SharingStarted.Eagerly, emptyList())
|
.stateIn(viewModelScope + Dispatchers.Default, SharingStarted.Eagerly, emptyList())
|
||||||
|
|
||||||
val relatedManga: StateFlow<List<MangaListModel>> = manga.mapLatest {
|
val relatedManga: StateFlow<List<MangaListModel>> = manga.mapLatest {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.catch
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
@@ -47,7 +46,7 @@ class ScrobblerConfigViewModel @Inject constructor(
|
|||||||
val content = scrobbler.observeAllScrobblingInfo()
|
val content = scrobbler.observeAllScrobblingInfo()
|
||||||
.onStart { loadingCounter.increment() }
|
.onStart { loadingCounter.increment() }
|
||||||
.onFirst { loadingCounter.decrement() }
|
.onFirst { loadingCounter.decrement() }
|
||||||
.catch { errorEvent.call(it) }
|
.withErrorHandling()
|
||||||
.map { buildContentList(it) }
|
.map { buildContentList(it) }
|
||||||
.stateIn(viewModelScope + Dispatchers.Default, SharingStarted.Eagerly, emptyList())
|
.stateIn(viewModelScope + Dispatchers.Default, SharingStarted.Eagerly, emptyList())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user