From f088a3a7fb87f5ffb444be213fceeabf678356dd Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 28 Sep 2026 10:48:33 -0400 Subject: [PATCH] perf(marmot): skip the relay-icon lookup for rows that show members' faces An unnamed, avatarless group (a White Noise 1:1) draws its members, but the row resolved the group picture first, a NIP-11 relay-info fetch per row that was then thrown away. The picture is now resolved only on the branch that draws it. Co-Authored-By: Claude Opus 5.5 --- .../chats/rooms/ChatroomHeaderCompose.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt index dd8634d812..d782720627 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt @@ -521,16 +521,6 @@ private fun MarmotGroupRoomCompose( val otherMembers = remember(members) { marmotOtherMembers(members, accountViewModel.account.signer.pubKey) } val groupName = marmotGroupTitle(displayName, otherMembers, chatroom.nostrGroupId, accountViewModel) - // Prefer the group's own avatar — the plain https link first, then the - // encrypted Blossom blob; when it has neither, fall back to the NIP-11 icon - // of one of the group's relays (fetched on a cache miss). - val channelPicture = - if (avatarUrl != null || image != null) { - rememberMarmotGroupAvatarUrl(avatarUrl, image, accountViewModel, adminPubkeys) - } else { - loadMarmotRelayIcon(relays) - } - // The row is handed the group's placeholder note when it has no messages. val lastContent = marmotGroupPreviewText(lastMessage.takeIf { it.event != null }, accountViewModel) @@ -551,6 +541,17 @@ private fun MarmotGroupRoomCompose( return } + // Prefer the group's own avatar — the plain https link first, then the + // encrypted Blossom blob; when it has neither, fall back to the NIP-11 icon + // of one of the group's relays (fetched on a cache miss). Resolved only here: a row that + // shows its members' faces above never draws it, and the relay icon is a NIP-11 fetch. + val channelPicture = + if (avatarUrl != null || image != null) { + rememberMarmotGroupAvatarUrl(avatarUrl, image, accountViewModel, adminPubkeys) + } else { + loadMarmotRelayIcon(relays) + } + ChannelName( channelIdHex = chatroom.nostrGroupId, channelPicture = channelPicture,