fix: suppress redundant reconnect sounds and broadcasts during active voice
This commit is contained in:
@@ -384,6 +384,23 @@ function handleVoiceJoin(event: Record<string, unknown>, userId: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the user is already in this exact channel (e.g. WS reconnect re-registration),
|
||||
// skip the leave+join broadcast to avoid visual flicker for other users.
|
||||
const currentChannel = connectionManager.getUserVoiceChannel(userId);
|
||||
if (currentChannel === channelId) {
|
||||
const status = connectionManager.getVoiceUserStatus(userId);
|
||||
if (status) {
|
||||
connectionManager.sendToServer(serverId, {
|
||||
type: 'voice_status_update',
|
||||
userId,
|
||||
channelId,
|
||||
isMuted: status.isMuted,
|
||||
isDeafened: status.isDeafened,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Leave any current voice channel
|
||||
const previousChannel = connectionManager.leaveAllVoice(userId);
|
||||
if (previousChannel) {
|
||||
|
||||
@@ -24,12 +24,15 @@ export function SoundController() {
|
||||
const incomingCallLoop = useRef<AudioBufferSourceNode | null>(null);
|
||||
const outgoingCallLoop = useRef<AudioBufferSourceNode | null>(null);
|
||||
|
||||
// WebSocket Reconnect Sound
|
||||
// WebSocket Reconnect Sound — suppress during active voice (LiveKit handles its own reconnection)
|
||||
useEffect(() => {
|
||||
if (isInitialMount.current) return;
|
||||
if (isWsConnected && !prevIsWsConnected.current) {
|
||||
const isInActiveVoice = useVoiceStore.getState().isLiveKitConnected;
|
||||
if (!isInActiveVoice) {
|
||||
audioManager.playSound('reconnect');
|
||||
}
|
||||
}
|
||||
prevIsWsConnected.current = isWsConnected;
|
||||
}, [isWsConnected, audioManager]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user