From 7b8c7a1a7835ebaf5bd9c1850fe1e8adb079d5ac Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 26 Aug 2024 18:22:12 -0400 Subject: [PATCH] Simplifies flow collection for new events. --- .../ui/screen/loggedIn/AccountViewModel.kt | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 6e3b124e3..4fbcac894 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -1197,23 +1197,21 @@ class AccountViewModel( init { Log.d("Init", "AccountViewModel") - viewModelScope.launch(Dispatchers.Default) { - feedStates.init() - // awaits for init to finish before starting to capture new events. + collectorJob = + viewModelScope.launch(Dispatchers.Default) { + feedStates.init() + // awaits for init to finish before starting to capture new events. - collectorJob = - viewModelScope.launch(Dispatchers.IO) { - LocalCache.live.newEventBundles.collect { newNotes -> - Log.d( - "Rendering Metrics", - "Notification Dots Calculation refresh ${this@AccountViewModel} for ${account.userProfile().toBestDisplayName()}", - ) - feedStates.updateFeedsWith(newNotes) - invalidateInsertData(newNotes) - upgradeAttestations() - } + LocalCache.live.newEventBundles.collect { newNotes -> + Log.d( + "Rendering Metrics", + "Notification Dots Calculation refresh ${this@AccountViewModel} for ${account.userProfile().toBestDisplayName()}", + ) + feedStates.updateFeedsWith(newNotes) + invalidateInsertData(newNotes) + upgradeAttestations() } - } + } } override fun onCleared() {