fix(jam): prevent self from showing in moderation menu

Fixes race condition where guest taking over as host would see 'manage'
button for themselves during presence propagation delay.

- Add localClientId to UI state combine
- Update canModerate logic: role == Host && !participant.isHost && participant.id != localClientId
This commit is contained in:
thumb2086 2026-10-31 01:28:16 +08:00
parent 848d9fdd0c
commit 983b0a4066

View File

@ -102,7 +102,9 @@ class JamViewModel(
codeCopied, codeCopied,
snapshotFlow { codeInput.text.toString() }, snapshotFlow { codeInput.text.toString() },
participantMenu, participantMenu,
isLeaving isLeaving,
// Local client ID to exclude self from moderation menu
jamRoomService.participantClientId
) { values -> ) { values ->
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
val role = values[0] as JamRole? val role = values[0] as JamRole?
@ -116,6 +118,7 @@ class JamViewModel(
val localError = values[6] as String? val localError = values[6] as String?
val busy = values[8] as Boolean val busy = values[8] as Boolean
val brokerConfigured = !settings?.jamBroker?.host.isNullOrBlank() val brokerConfigured = !settings?.jamBroker?.host.isNullOrBlank()
val localClientId = values[13] as String
JamUiState( JamUiState(
isActive = role != null, isActive = role != null,
@ -127,7 +130,8 @@ class JamViewModel(
displayName = participant.displayName, displayName = participant.displayName,
initial = participant.displayName.firstOrNull()?.uppercase() ?: "?", initial = participant.displayName.firstOrNull()?.uppercase() ?: "?",
isHost = participant.isHost, isHost = participant.isHost,
canModerate = role == JamRole.Host && !participant.isHost, // Host can moderate OTHER participants only (not self)
canModerate = role == JamRole.Host && !participant.isHost && participant.id != localClientId,
menuExpanded = values[11] == participant.id menuExpanded = values[11] == participant.id
) )
}, },