From 8d3565c12495c6de60207c3f7048751d2c527096 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 28 Sep 2026 10:47:48 -0400 Subject: [PATCH] fix(marmot): a group's preview shows the edited text of its last message The Marmot list row and the Messages-tab row read the last message's original content, so after an edit the bubble showed the new text and the rows kept the old one. The preview now observes the message's edits, the same overlay the bubble draws. Checked on the tablet: editing the newest message updates the Messages row. Co-Authored-By: Claude Opus 5.5 --- .../loggedIn/chats/marmotGroup/MarmotGroupPreview.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/marmotGroup/MarmotGroupPreview.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/marmotGroup/MarmotGroupPreview.kt index 2c297319c3..4130dc30d5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/marmotGroup/MarmotGroupPreview.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/marmotGroup/MarmotGroupPreview.kt @@ -35,6 +35,7 @@ import com.vitorpamplona.amethyst.commons.resources.marmot_preview_with_sender import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserInfo import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.feed.observeChatEdit import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.feed.types.hasEncryptedMediaV2 import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.feed.types.hasMip04Media import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.feed.types.observeUserNameByHex @@ -58,6 +59,10 @@ fun marmotGroupPreviewText( // to render as a blank second line under the group name. val myPubKey = accountViewModel.account.signer.pubKey val previewEvent = newestMessage?.event + // An edited last message previews its new text, as its bubble does. Observed rather than + // read once so an edit arriving while the list is open updates the row. + val editedContent = newestMessage?.let { observeChatEdit(it) }?.event?.content + val shownText = editedContent ?: previewEvent?.content.orEmpty() val previewBody = when { newestMessage == null -> stringRes(Res.string.marmot_no_messages_yet) @@ -66,7 +71,7 @@ fun marmotGroupPreviewText( // Text first: an attachment usually carries a caption, and showing // "Attachment" over the words the sender actually wrote would be a // step back from the raw `content` this replaced. - previewEvent.content.isNotBlank() -> previewEvent.content + shownText.isNotBlank() -> shownText hasMip04Media(previewEvent) || hasEncryptedMediaV2(previewEvent) -> stringRes(Res.string.marmot_preview_media) else -> stringRes(Res.string.marmot_preview_no_text) }