From 1e83dbfbe356ef050ac34ffdb3ce094b0d6e8181 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 17 Oct 2023 18:09:39 -0400 Subject: [PATCH] Only changes Username if value changes. --- .../java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt index ae8f1d948..21c9ba047 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.distinctUntilChanged import androidx.lifecycle.map import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.User @@ -35,7 +36,7 @@ import com.vitorpamplona.quartz.events.ImmutableListOfLists fun NoteUsernameDisplay(baseNote: Note, weight: Modifier = Modifier, showPlayButton: Boolean = true, textColor: Color = Color.Unspecified) { val authorState by baseNote.live().metadata.map { it.note.author - }.observeAsState(baseNote.author) + }.distinctUntilChanged().observeAsState(baseNote.author) Crossfade(targetState = authorState, modifier = weight) { it?.let {