From 0320ccf4a068b4256c4da85366b1e5c089222c0a Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Fri, 6 Mar 2026 08:15:33 -0300 Subject: [PATCH] perf: optimize state management and clean up styling in ReactionsSettingsScreen - Change `items` state initialization to use `toList()` instead of `toMutableList()` to ensure a fresh immutable snapshot from the flow. - Reformat chained modifiers in `DraggableItem` for better readability. --- .../screen/loggedIn/settings/ReactionsSettingsScreen.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ReactionsSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ReactionsSettingsScreen.kt index 968b6beff..c6708c737 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ReactionsSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ReactionsSettingsScreen.kt @@ -87,7 +87,7 @@ fun ReactionsSettingsScreen( @Composable fun ReactionsSettingsContent(accountViewModel: AccountViewModel) { val reactionRowItems by accountViewModel.reactionRowItemsFlow().collectAsStateWithLifecycle() - var items by remember(reactionRowItems) { mutableStateOf(reactionRowItems.toMutableList()) } + var items by remember(reactionRowItems) { mutableStateOf(reactionRowItems.toList()) } fun save(newItems: List) { items = newItems.toMutableList() @@ -238,16 +238,14 @@ private fun ReactionRowItemCard( .fillMaxWidth() .onGloballyPositioned { coordinates -> onMeasured(coordinates.size.height.toFloat()) - } - .graphicsLayer { + }.graphicsLayer { translationY = dragOffsetY shadowElevation = elevation if (isDragging) { scaleX = 1.02f scaleY = 1.02f } - } - .padding(vertical = 8.dp), + }.padding(vertical = 8.dp), ) { Row( modifier = Modifier.fillMaxWidth(),