Adjusting zap calculations

pull/914/head
Vitor Pamplona 2024-06-14 08:31:06 -04:00
rodzic 52a24d5223
commit 39efc2ef9b
2 zmienionych plików z 19 dodań i 15 usunięć

Wyświetl plik

@ -44,6 +44,7 @@ import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
@ -163,18 +164,7 @@ private fun Galeries(
nav: (String) -> Unit,
) {
if (multiSetCard.zapEvents.isNotEmpty()) {
var zapEvents by
remember(multiSetCard) {
mutableStateOf(
accountViewModel.cachedDecryptAmountMessageInGroup(multiSetCard.zapEvents),
)
}
LaunchedEffect(key1 = Unit) {
accountViewModel.decryptAmountMessageInGroup(multiSetCard.zapEvents) { zapEvents = it }
}
RenderZapGallery(zapEvents, backgroundColor, nav, accountViewModel)
DecryptAndRenderZapGallery(multiSetCard, backgroundColor, accountViewModel, nav)
}
if (multiSetCard.boostEvents.isNotEmpty()) {
@ -229,12 +219,27 @@ fun RenderLikeGallery(
}
}
@Composable
fun DecryptAndRenderZapGallery(
multiSetCard: MultiSetCard,
backgroundColor: MutableState<Color>,
accountViewModel: AccountViewModel,
nav: (String) -> Unit,
) {
val zapEvents by
produceState(initialValue = accountViewModel.cachedDecryptAmountMessageInGroup(multiSetCard.zapEvents)) {
accountViewModel.decryptAmountMessageInGroup(multiSetCard.zapEvents) { value = it }
}
RenderZapGallery(zapEvents, backgroundColor, accountViewModel, nav)
}
@Composable
fun RenderZapGallery(
zapEvents: ImmutableList<ZapAmountCommentNotification>,
backgroundColor: MutableState<Color>,
nav: (String) -> Unit,
accountViewModel: AccountViewModel,
nav: (String) -> Unit,
) {
Row(Modifier.fillMaxWidth()) {
Box(

Wyświetl plik

@ -34,7 +34,6 @@ import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
@ -494,8 +493,8 @@ private fun WatchZapAndRenderGallery(
RenderZapGallery(
zapEvents,
backgroundColor,
nav,
accountViewModel,
nav,
)
}
}