fix(ui): show NIP-29 group names in the picker, not their ids

The read-only settings picker never fetches a group's kind-39000 metadata, so with
no cached event RelayGroupChannel.toBestDisplayName() fell back to the raw group id.
Resolve the label from the group's metadata name when loaded, otherwise the name the
user's joined-groups list already stored for it (the NIP-51 ["group", id, relay, name]
tag), and only then the id. Also helps the live bar before 39000 arrives.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mxdSFQcarsKaL179tSub1
This commit is contained in:
Claude
2026-07-15 18:33:19 +00:00
parent e1a9a5cd7e
commit 7dc033ec79
@@ -110,8 +110,21 @@ fun rememberRelayGroupEntryDisplay(
// call structure is unconditional; a null channel just yields a null state and the id fallback.
val state by observeChannelMetadataOrNull(channel, accountViewModel, subscribe)
val current = (state?.channel as? RelayGroupChannel) ?: channel
// The name from the group's own kind-39000 metadata, once it has loaded.
val metaName = current?.event?.name()?.ifBlank { null }
// Otherwise the name the user's joined-groups list stored for this group (the NIP-51
// ["group", id, relay, name] tag) — so the row reads as a name even before 39000 is fetched,
// which the read-only settings picker never does.
val joined by accountViewModel.account.relayGroupList.liveRelayGroupList
.collectAsStateWithLifecycle()
val tagName =
remember(joined, entry) {
joined.firstOrNull { it.groupId == entry.groupId && it.relayUrl == entry.relayUrl }?.name?.ifBlank { null }
}
return GroupEntryDisplay(
label = current?.toBestDisplayName() ?: entry.groupId,
label = metaName ?: tagName ?: entry.groupId,
robotSeed = entry.groupId,
model = current?.profilePicture(),
route = Route.RelayGroup(entry.groupId, entry.relayUrl),