fix: sync channel sidebar voice users with LiveKit participant disconnects

The sidebar used voiceStore.voiceUsers (WebSocket-driven, 5s delay) while
voice panels used LiveKit's real-time participants. Now ParticipantDisconnected
also removes the user from voiceUsers for immediate sidebar updates.
This commit is contained in:
Jannis Braun
2026-03-16 20:41:36 +01:00
parent e9c43f21f1
commit e809adff3e
+11 -1
View File
@@ -412,7 +412,17 @@ export function useLiveKit() {
).catch(() => { });
}
});
newRoom.on(RoomEvent.ParticipantDisconnected, guardedUpdate);
newRoom.on(RoomEvent.ParticipantDisconnected, (participant: RemoteParticipant) => {
guardedUpdate();
// Sync voiceUsers so channel sidebar updates immediately
// (don't wait for server's 5s grace-period WS event)
const chId = connectedChannelRef.current;
if (chId && !chId.startsWith('dm-')) {
const { userId } = parseIdentity(participant.identity);
useVoiceStore.getState().removeVoiceUser(chId, userId);
useVoiceStore.getState().clearVoiceUserStatus(userId);
}
});
newRoom.on(RoomEvent.TrackSubscribed, (track, publication, participant) => {
// LiveKit auto-attaches a hidden <audio> element for subscribed audio tracks.
// GlobalAudioRenderer is the sole audio playback path with volume/attenuation/boost.