From e7b7ebbbdfa4f2b52c7d80d7419dd33cd3ef1dda Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 2 Jun 2023 21:28:50 -0400 Subject: [PATCH] Adds a new thread call for the notification of reaction rows --- .../amethyst/ui/note/UserReactionsRow.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt index 93c1e5957..082bfec3d 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserReactionsRow.kt @@ -43,6 +43,7 @@ import com.vitorpamplona.amethyst.service.model.LnZapEvent import com.vitorpamplona.amethyst.service.model.ReactionEvent import com.vitorpamplona.amethyst.service.model.RepostEvent import com.vitorpamplona.amethyst.service.model.TextNoteEvent +import com.vitorpamplona.amethyst.ui.components.BundledInsert import com.vitorpamplona.amethyst.ui.screen.loggedIn.showAmountAxis import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange import com.vitorpamplona.amethyst.ui.theme.RoyalBlue @@ -280,12 +281,20 @@ class UserReactionsViewModel(val account: Account) : ViewModel() { collectorJob = viewModelScope.launch(Dispatchers.IO) { LocalCache.live.newEventBundles.collect { newNotes -> - addToStatsSuspend(newNotes) + invalidateInsertData(newNotes) } } } } + private val bundlerInsert = BundledInsert>(250, Dispatchers.IO) + + fun invalidateInsertData(newItems: Set) { + bundlerInsert.invalidateList(newItems) { + addToStatsSuspend(it.flatten().toSet()) + } + } + override fun onCleared() { super.onCleared() }