Skip to content

Commit

Permalink
Moves zapProgress to inside the IO update to make sure it only update…
Browse files Browse the repository at this point in the history
…s when needed.
  • Loading branch information
vitorpamplona committed May 22, 2023
1 parent 0a8c79d commit 6437a21
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -331,15 +331,15 @@ fun ZapReaction(
animationSize: Dp = 14.dp
) {
val accountState by accountViewModel.accountLiveData.observeAsState()
val account = accountState?.account ?: return
val account = remember(accountState) { accountState?.account } ?: return

val zapsState by baseNote.live().zaps.observeAsState()
val zappedNote = zapsState?.note ?: return
val zapMessage = ""
val zappedNote = remember(zapsState) { zapsState?.note } ?: return

var wantsToZap by remember { mutableStateOf(false) }
var wantsToChangeZapAmount by remember { mutableStateOf(false) }
var wantsToSetCustomZap by remember { mutableStateOf(false) }

val context = LocalContext.current
val scope = rememberCoroutineScope()

Expand All @@ -352,6 +352,7 @@ fun ZapReaction(
scope.launch(Dispatchers.IO) {
if (!wasZappedByLoggedInUser) {
wasZappedByLoggedInUser = accountViewModel.calculateIfNoteWasZappedByAccount(zappedNote)
zappingProgress = 1f
}

zapAmountTxt = showAmount(account.calculateZappedAmount(zappedNote))
Expand Down Expand Up @@ -393,7 +394,7 @@ fun ZapReaction(
baseNote,
account.zapAmountChoices.first() * 1000,
null,
zapMessage,
"",
context,
onError = {
scope.launch {
Expand Down Expand Up @@ -457,7 +458,6 @@ fun ZapReaction(
}

if (wasZappedByLoggedInUser) {
zappingProgress = 1f
Icon(
imageVector = Icons.Default.Bolt,
contentDescription = stringResource(R.string.zaps),
Expand Down

0 comments on commit 6437a21

Please sign in to comment.