Adds a new thread call for the notification of reaction rows

This commit is contained in:
Vitor Pamplona
2023-06-02 21:28:50 -04:00
parent 5965d9a3bb
commit e7b7ebbbdf
@@ -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<Set<Note>>(250, Dispatchers.IO)
fun invalidateInsertData(newItems: Set<Note>) {
bundlerInsert.invalidateList(newItems) {
addToStatsSuspend(it.flatten().toSet())
}
}
override fun onCleared() {
super.onCleared()
}