From 2c41d989ac2c5c992b68a63db6700ec42b6856b8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 26 Apr 2026 21:59:21 +0000 Subject: [PATCH] feat(audio-rooms): listener counter badge on the full-screen room view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renders "%d listeners" right under the room title once the kind-10312 aggregator has at least one entry. Counts every peer with a recent presence event — hosts, speakers, and audience alike — matching what the nostrnests web UI shows in its room header. The badge uses a pluralized string resource so the wire copy matches locale rules (one / many) without per-locale code paths. Hidden when the count is zero so a brand-new room (before anyone's presence has propagated) doesn't flash a misleading "0 listeners". Counts can flicker briefly when a single peer drops a heartbeat — the eviction window in AudioRoomActivityContent is 6 min so a short relay hiccup doesn't flip the count, but the badge will move when peers genuinely come and go. --- .../audiorooms/room/AudioRoomFullScreen.kt | 20 +++++++++++++++++++ amethyst/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/audiorooms/room/AudioRoomFullScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/audiorooms/room/AudioRoomFullScreen.kt index 2fa567134e..aa7e311a85 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/audiorooms/room/AudioRoomFullScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/audiorooms/room/AudioRoomFullScreen.kt @@ -40,6 +40,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable @@ -103,6 +104,25 @@ internal fun AudioRoomFullScreen( ) } + // Listener counter — counts every active kind-10312 presence + // in the room. Hidden until the aggregator has at least one + // entry so the placeholder doesn't flash on entry. + val presences by viewModel.presences.collectAsState() + val listenerCount = presences.size + if (listenerCount > 0) { + Text( + text = + androidx.compose.ui.res.pluralStringResource( + R.plurals.audio_room_listener_count, + listenerCount, + listenerCount, + ), + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(top = 4.dp), + ) + } + if (onStage.isNotEmpty()) { StagePeopleRow( label = stringRes(R.string.audio_room_stage), diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml index ba13d443e0..18b489eb66 100644 --- a/amethyst/src/main/res/values/strings.xml +++ b/amethyst/src/main/res/values/strings.xml @@ -521,6 +521,10 @@ Stop Join audio room Leave + + %1$d listener + %1$d listeners + Start space Start a new audio room Room name