mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 08:27:04 +00:00
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:
+20
@@ -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),
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user