From 914c0a2926071360d75af0b4447b41cc79023425 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 26 Aug 2024 19:12:28 -0400 Subject: [PATCH] Making sure scopes are cancelled for accountViewModel notification dot updates. --- .../amethyst/ui/screen/loggedIn/AccountViewModel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 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 4fbcac894..394d8cf18 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 @@ -1181,7 +1181,7 @@ class AccountViewModel( private var collectorJob: Job? = null val notificationDots = HasNotificationDot(bottomNavigationItems) - private val bundlerInsert = BundledInsert>(3000, Dispatchers.IO) + private val bundlerInsert = BundledInsert>(3000, Dispatchers.Default) fun invalidateInsertData(newItems: Set) { bundlerInsert.invalidateList(newItems) { updateNotificationDots(it.flatten().toSet()) } @@ -1201,7 +1201,6 @@ class AccountViewModel( viewModelScope.launch(Dispatchers.Default) { feedStates.init() // awaits for init to finish before starting to capture new events. - LocalCache.live.newEventBundles.collect { newNotes -> Log.d( "Rendering Metrics", @@ -1217,6 +1216,7 @@ class AccountViewModel( override fun onCleared() { Log.d("Init", "AccountViewModel onCleared") feedStates.destroy() + bundlerInsert.cancel() collectorJob?.cancel() super.onCleared() }