mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-12 05:49:30 +02:00
Removing unnecessary modifiers and remember calls
This commit is contained in:
parent
ca8d32b837
commit
52a24d5223
@ -41,7 +41,6 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@ -118,15 +117,15 @@ fun MultiSetCompose(
|
||||
|
||||
val columnModifier =
|
||||
remember(backgroundColor.value) {
|
||||
Modifier.fillMaxWidth()
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.background(backgroundColor.value)
|
||||
.combinedClickable(
|
||||
onClick = {
|
||||
scope.launch { routeFor(baseNote, accountViewModel.userProfile())?.let { nav(it) } }
|
||||
},
|
||||
onLongClick = enablePopup,
|
||||
)
|
||||
.padding(
|
||||
).padding(
|
||||
start = 12.dp,
|
||||
end = 12.dp,
|
||||
top = 10.dp,
|
||||
@ -163,13 +162,9 @@ private fun Galeries(
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: (String) -> Unit,
|
||||
) {
|
||||
val hasZapEvents by remember { derivedStateOf { multiSetCard.zapEvents.isNotEmpty() } }
|
||||
val hasBoostEvents by remember { derivedStateOf { multiSetCard.boostEvents.isNotEmpty() } }
|
||||
val hasLikeEvents by remember { derivedStateOf { multiSetCard.likeEvents.isNotEmpty() } }
|
||||
|
||||
if (hasZapEvents) {
|
||||
if (multiSetCard.zapEvents.isNotEmpty()) {
|
||||
var zapEvents by
|
||||
remember(multiSetCard.zapEvents) {
|
||||
remember(multiSetCard) {
|
||||
mutableStateOf(
|
||||
accountViewModel.cachedDecryptAmountMessageInGroup(multiSetCard.zapEvents),
|
||||
)
|
||||
@ -182,11 +177,11 @@ private fun Galeries(
|
||||
RenderZapGallery(zapEvents, backgroundColor, nav, accountViewModel)
|
||||
}
|
||||
|
||||
if (hasBoostEvents) {
|
||||
if (multiSetCard.boostEvents.isNotEmpty()) {
|
||||
RenderBoostGallery(multiSetCard.boostEvents, nav, accountViewModel)
|
||||
}
|
||||
|
||||
if (hasLikeEvents) {
|
||||
if (multiSetCard.likeEvents.isNotEmpty()) {
|
||||
multiSetCard.likeEventsByType.forEach {
|
||||
RenderLikeGallery(it.key, it.value, nav, accountViewModel)
|
||||
}
|
||||
|
@ -137,7 +137,6 @@ import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.ImmutableSet
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableMap
|
||||
import kotlinx.collections.immutable.toImmutableSet
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@ -270,7 +269,10 @@ private fun LoadAndDisplayZapraiser(
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable data class ZapraiserStatus(val progress: Float, val left: String)
|
||||
@Immutable data class ZapraiserStatus(
|
||||
val progress: Float,
|
||||
val left: String,
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun RenderZapRaiser(
|
||||
@ -453,12 +455,11 @@ private fun WatchReactionsAndRenderGallery(
|
||||
accountViewModel: AccountViewModel,
|
||||
) {
|
||||
val reactionsState by baseNote.live().reactions.observeAsState()
|
||||
val reactionEvents by
|
||||
remember(reactionsState) { derivedStateOf { baseNote.reactions.toImmutableMap() } }
|
||||
val reactionEvents = reactionsState?.note?.reactions ?: return
|
||||
|
||||
if (reactionEvents.isNotEmpty()) {
|
||||
reactionEvents.forEach {
|
||||
val reactions = remember(it.value) { it.value.toImmutableList() }
|
||||
val reactions = remember(it.key) { it.value.toImmutableList() }
|
||||
RenderLikeGallery(
|
||||
it.key,
|
||||
reactions,
|
||||
@ -636,9 +637,7 @@ private fun SlidingAnimationCount(
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
private fun <S> AnimatedContentTransitionScope<S>.transitionSpec(): ContentTransform {
|
||||
return slideAnimation
|
||||
}
|
||||
private fun <S> AnimatedContentTransitionScope<S>.transitionSpec(): ContentTransform = slideAnimation
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
val slideAnimation: ContentTransform =
|
||||
@ -647,13 +646,12 @@ val slideAnimation: ContentTransform =
|
||||
fadeIn(
|
||||
animationSpec = tween(durationMillis = 100),
|
||||
)
|
||||
).togetherWith(
|
||||
slideOutVertically(animationSpec = tween(durationMillis = 100)) { height -> -height } +
|
||||
fadeOut(
|
||||
animationSpec = tween(durationMillis = 100),
|
||||
),
|
||||
)
|
||||
.togetherWith(
|
||||
slideOutVertically(animationSpec = tween(durationMillis = 100)) { height -> -height } +
|
||||
fadeOut(
|
||||
animationSpec = tween(durationMillis = 100),
|
||||
),
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun TextCount(
|
||||
@ -744,10 +742,9 @@ fun ObserveBoostIcon(
|
||||
.boosts
|
||||
.map { it.note.isBoostedBy(accountViewModel.userProfile()) }
|
||||
.distinctUntilChanged()
|
||||
}
|
||||
.observeAsState(
|
||||
baseNote.isBoostedBy(accountViewModel.userProfile()),
|
||||
)
|
||||
}.observeAsState(
|
||||
baseNote.isBoostedBy(accountViewModel.userProfile()),
|
||||
)
|
||||
|
||||
inner(hasBoosted)
|
||||
}
|
||||
@ -1066,8 +1063,7 @@ fun ZapReaction(
|
||||
targetValue = zappingProgress,
|
||||
animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
|
||||
label = "ZapIconIndicator",
|
||||
)
|
||||
.value,
|
||||
).value,
|
||||
modifier = remember { Modifier.size(animationSize) },
|
||||
strokeWidth = 2.dp,
|
||||
)
|
||||
@ -1210,7 +1206,8 @@ private fun DrawViewCount(
|
||||
AsyncImage(
|
||||
model =
|
||||
remember(note) {
|
||||
ImageRequest.Builder(context)
|
||||
ImageRequest
|
||||
.Builder(context)
|
||||
.data("https://counter.amethyst.social/${note.idHex}.svg?label=+&color=00000000")
|
||||
.diskCachePolicy(CachePolicy.DISABLED)
|
||||
.memoryCachePolicy(CachePolicy.ENABLED)
|
||||
|
@ -60,7 +60,6 @@ fun RenderNIP90ContentDiscoveryResponse(
|
||||
nav: (String) -> Unit,
|
||||
) {
|
||||
val noteEvent = note.event
|
||||
val modifier = remember(note) { Modifier.fillMaxWidth() }
|
||||
|
||||
val showReply by
|
||||
remember(note) {
|
||||
|
@ -20,7 +20,6 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.ui.note.types
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
@ -28,7 +27,6 @@ import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.ui.components.GenericLoadable
|
||||
@ -51,7 +49,6 @@ fun RenderNIP90Status(
|
||||
nav: (String) -> Unit,
|
||||
) {
|
||||
val noteEvent = note.event
|
||||
val modifier = remember(note) { Modifier.fillMaxWidth() }
|
||||
|
||||
val showReply by
|
||||
remember(note) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user