feat(audio-rooms): listener counter badge on the full-screen room view

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.
This commit is contained in:
Claude
2026-04-26 21:59:21 +00:00
parent 9b4f2e394d
commit 2c41d989ac
2 changed files with 24 additions and 0 deletions
@@ -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),
+4
View File
@@ -521,6 +521,10 @@
<string name="audio_room_notification_stop">Stop</string>
<string name="audio_room_join">Join audio room</string>
<string name="audio_room_leave">Leave</string>
<plurals name="audio_room_listener_count">
<item quantity="one">%1$d listener</item>
<item quantity="other">%1$d listeners</item>
</plurals>
<string name="audio_room_create_fab">Start space</string>
<string name="audio_room_create_title">Start a new audio room</string>
<string name="audio_room_create_field_room">Room name</string>