Minor adjustments in threading

This commit is contained in:
Vitor Pamplona
2023-06-26 20:38:06 -04:00
parent 833e6bc3e1
commit 52af109b4e
3 changed files with 18 additions and 8 deletions
@@ -55,7 +55,7 @@ open class Event(
}
override fun zapraiserAmount() = tags.firstOrNull() {
(it.size > 1 && it[0].equals("zapraiser", true))
(it.size > 1 && it[0] == "zapraiser")
}?.get(1)?.toLongOrNull()
override fun zapAddress() = tags.firstOrNull { it.size > 1 && it[0] == "zap" }?.get(1)
@@ -22,7 +22,6 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.CircularProgressIndicator
@@ -83,6 +82,7 @@ import com.vitorpamplona.amethyst.ui.theme.Font14SP
import com.vitorpamplona.amethyst.ui.theme.HalfDoubleVertSpacer
import com.vitorpamplona.amethyst.ui.theme.HalfStartPadding
import com.vitorpamplona.amethyst.ui.theme.Height4dpModifier
import com.vitorpamplona.amethyst.ui.theme.ModifierWidth3dp
import com.vitorpamplona.amethyst.ui.theme.NoSoTinyBorders
import com.vitorpamplona.amethyst.ui.theme.ReactionRowExpandButton
import com.vitorpamplona.amethyst.ui.theme.ReactionRowHeight
@@ -522,7 +522,7 @@ private fun SlidingAnimation(baseCount: Int, textColor: Color) {
}
) { count ->
Text(
text = remember { showCount(count) },
text = remember(count) { showCount(count) },
fontSize = Font14SP,
color = textColor,
modifier = HalfStartPadding,
@@ -723,7 +723,9 @@ fun LikeIcon(
launch(Dispatchers.Default) {
val newReactionType = reactionsState?.note?.isReactedBy(accountViewModel.userProfile())?.firstFullChar()
if (reactionType != newReactionType) {
reactionType = newReactionType
launch(Dispatchers.Main) {
reactionType = newReactionType
}
}
}
}
@@ -791,7 +793,9 @@ fun LikeText(baseNote: Note, grayTint: Color) {
launch(Dispatchers.Default) {
val newReactionsCount = reactionsState?.note?.countReactions() ?: 0
if (reactionsCount != newReactionsCount) {
reactionsCount = newReactionsCount
launch(Dispatchers.Main) {
reactionsCount = newReactionsCount
}
}
}
}
@@ -923,7 +927,7 @@ fun ZapReaction(
}
if (zappingProgress > 0.00001 && zappingProgress < 0.99999) {
Spacer(Modifier.width(3.dp))
Spacer(ModifierWidth3dp)
CircularProgressIndicator(
progress = animateFloatAsState(
@@ -1020,7 +1024,9 @@ private fun ZapIcon(
val newWasZapped = accountViewModel.calculateIfNoteWasZappedByAccount(it)
if (wasZappedByLoggedInUser != newWasZapped) {
wasZappedByLoggedInUser = newWasZapped
launch(Dispatchers.Main) {
wasZappedByLoggedInUser = newWasZapped
}
}
}
}
@@ -1061,7 +1067,9 @@ private fun ZapAmountText(
zapsState?.note?.let {
val newZapAmount = showAmount(accountViewModel.calculateZapAmount(it))
if (newZapAmount != zapAmountTxt) {
zapAmountTxt = newZapAmount
launch(Dispatchers.Main) {
zapAmountTxt = newZapAmount
}
}
}
}
@@ -90,3 +90,5 @@ val ShowMoreRelaysButtonIconModifier = Modifier.size(15.dp)
val ShowMoreRelaysButtonBoxModifer = Modifier.fillMaxWidth().height(25.dp)
val ChatBubbleMaxSizeModifier = Modifier.fillMaxWidth(0.85f)
val ModifierWidth3dp = Modifier.width(3.dp)