Minor adjustments in threading
This commit is contained in:
@@ -55,7 +55,7 @@ open class Event(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun zapraiserAmount() = tags.firstOrNull() {
|
override fun zapraiserAmount() = tags.firstOrNull() {
|
||||||
(it.size > 1 && it[0].equals("zapraiser", true))
|
(it.size > 1 && it[0] == "zapraiser")
|
||||||
}?.get(1)?.toLongOrNull()
|
}?.get(1)?.toLongOrNull()
|
||||||
|
|
||||||
override fun zapAddress() = tags.firstOrNull { it.size > 1 && it[0] == "zap" }?.get(1)
|
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.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
|
||||||
import androidx.compose.material.Button
|
import androidx.compose.material.Button
|
||||||
import androidx.compose.material.ButtonDefaults
|
import androidx.compose.material.ButtonDefaults
|
||||||
import androidx.compose.material.CircularProgressIndicator
|
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.HalfDoubleVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.HalfStartPadding
|
import com.vitorpamplona.amethyst.ui.theme.HalfStartPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Height4dpModifier
|
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.NoSoTinyBorders
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ReactionRowExpandButton
|
import com.vitorpamplona.amethyst.ui.theme.ReactionRowExpandButton
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ReactionRowHeight
|
import com.vitorpamplona.amethyst.ui.theme.ReactionRowHeight
|
||||||
@@ -522,7 +522,7 @@ private fun SlidingAnimation(baseCount: Int, textColor: Color) {
|
|||||||
}
|
}
|
||||||
) { count ->
|
) { count ->
|
||||||
Text(
|
Text(
|
||||||
text = remember { showCount(count) },
|
text = remember(count) { showCount(count) },
|
||||||
fontSize = Font14SP,
|
fontSize = Font14SP,
|
||||||
color = textColor,
|
color = textColor,
|
||||||
modifier = HalfStartPadding,
|
modifier = HalfStartPadding,
|
||||||
@@ -723,10 +723,12 @@ fun LikeIcon(
|
|||||||
launch(Dispatchers.Default) {
|
launch(Dispatchers.Default) {
|
||||||
val newReactionType = reactionsState?.note?.isReactedBy(accountViewModel.userProfile())?.firstFullChar()
|
val newReactionType = reactionsState?.note?.isReactedBy(accountViewModel.userProfile())?.firstFullChar()
|
||||||
if (reactionType != newReactionType) {
|
if (reactionType != newReactionType) {
|
||||||
|
launch(Dispatchers.Main) {
|
||||||
reactionType = newReactionType
|
reactionType = newReactionType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Crossfade(targetState = reactionType) {
|
Crossfade(targetState = reactionType) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
@@ -791,10 +793,12 @@ fun LikeText(baseNote: Note, grayTint: Color) {
|
|||||||
launch(Dispatchers.Default) {
|
launch(Dispatchers.Default) {
|
||||||
val newReactionsCount = reactionsState?.note?.countReactions() ?: 0
|
val newReactionsCount = reactionsState?.note?.countReactions() ?: 0
|
||||||
if (reactionsCount != newReactionsCount) {
|
if (reactionsCount != newReactionsCount) {
|
||||||
|
launch(Dispatchers.Main) {
|
||||||
reactionsCount = newReactionsCount
|
reactionsCount = newReactionsCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SlidingAnimation(reactionsCount, grayTint)
|
SlidingAnimation(reactionsCount, grayTint)
|
||||||
}
|
}
|
||||||
@@ -923,7 +927,7 @@ fun ZapReaction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (zappingProgress > 0.00001 && zappingProgress < 0.99999) {
|
if (zappingProgress > 0.00001 && zappingProgress < 0.99999) {
|
||||||
Spacer(Modifier.width(3.dp))
|
Spacer(ModifierWidth3dp)
|
||||||
|
|
||||||
CircularProgressIndicator(
|
CircularProgressIndicator(
|
||||||
progress = animateFloatAsState(
|
progress = animateFloatAsState(
|
||||||
@@ -1020,12 +1024,14 @@ private fun ZapIcon(
|
|||||||
val newWasZapped = accountViewModel.calculateIfNoteWasZappedByAccount(it)
|
val newWasZapped = accountViewModel.calculateIfNoteWasZappedByAccount(it)
|
||||||
|
|
||||||
if (wasZappedByLoggedInUser != newWasZapped) {
|
if (wasZappedByLoggedInUser != newWasZapped) {
|
||||||
|
launch(Dispatchers.Main) {
|
||||||
wasZappedByLoggedInUser = newWasZapped
|
wasZappedByLoggedInUser = newWasZapped
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Crossfade(targetState = wasZappedByLoggedInUser) {
|
Crossfade(targetState = wasZappedByLoggedInUser) {
|
||||||
if (it) {
|
if (it) {
|
||||||
@@ -1061,11 +1067,13 @@ private fun ZapAmountText(
|
|||||||
zapsState?.note?.let {
|
zapsState?.note?.let {
|
||||||
val newZapAmount = showAmount(accountViewModel.calculateZapAmount(it))
|
val newZapAmount = showAmount(accountViewModel.calculateZapAmount(it))
|
||||||
if (newZapAmount != zapAmountTxt) {
|
if (newZapAmount != zapAmountTxt) {
|
||||||
|
launch(Dispatchers.Main) {
|
||||||
zapAmountTxt = newZapAmount
|
zapAmountTxt = newZapAmount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SlidingAnimation(zapAmountTxt, grayTint)
|
SlidingAnimation(zapAmountTxt, grayTint)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,3 +90,5 @@ val ShowMoreRelaysButtonIconModifier = Modifier.size(15.dp)
|
|||||||
val ShowMoreRelaysButtonBoxModifer = Modifier.fillMaxWidth().height(25.dp)
|
val ShowMoreRelaysButtonBoxModifer = Modifier.fillMaxWidth().height(25.dp)
|
||||||
|
|
||||||
val ChatBubbleMaxSizeModifier = Modifier.fillMaxWidth(0.85f)
|
val ChatBubbleMaxSizeModifier = Modifier.fillMaxWidth(0.85f)
|
||||||
|
|
||||||
|
val ModifierWidth3dp = Modifier.width(3.dp)
|
||||||
|
|||||||
Reference in New Issue
Block a user