Handle async cache in updates and manga screens

- Also fix concurrent accesses to main cache map
- Also debounce sources and updates list updates to maybe avoid crashing due to dupe LazyColumn keys
This commit is contained in:
arkon
2022-10-22 10:50:44 -04:00
parent d558f9e1d6
commit 152eb5b951
7 changed files with 64 additions and 69 deletions
@@ -16,6 +16,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.receiveAsFlow
import logcat.LogPriority
import uy.kohesive.injekt.Injekt
@@ -38,6 +39,7 @@ class SourcesPresenter(
fun onCreate() {
presenterScope.launchIO {
getEnabledSources.subscribe()
.debounce(500) // Avoid crashes due to LazyColumn rendering
.catch { exception ->
logcat(LogPriority.ERROR, exception)
_events.send(Event.FailedFetchingSources)