Moves reward calculations to the IO thread

This commit is contained in:
Vitor Pamplona
2023-06-02 21:27:57 -04:00
parent 8e16daaaa3
commit 31959721b1
@@ -1712,11 +1712,17 @@ private fun RenderPledgeAmount(
}
LaunchedEffect(key1 = repliesState) {
withContext(Dispatchers.IO) {
launch(Dispatchers.IO) {
repliesState?.note?.pledgedAmountByOthers()?.let {
rewardAmount = baseReward.add(it)
val newRewardAmount = baseReward.add(it)
if (newRewardAmount != rewardAmount) {
rewardAmount = newRewardAmount
}
}
val newHasPledge = repliesState?.note?.hasPledgeBy(accountViewModel.userProfile()) == true
if (hasPledge != newHasPledge) {
hasPledge = newHasPledge
}
hasPledge = repliesState?.note?.hasPledgeBy(accountViewModel.userProfile()) == true
}
}