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;
|
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
|
// Leave any current voice channel
|
||||||
const previousChannel = connectionManager.leaveAllVoice(userId);
|
const previousChannel = connectionManager.leaveAllVoice(userId);
|
||||||
if (previousChannel) {
|
if (previousChannel) {
|
||||||
|
|||||||
@@ -24,11 +24,14 @@ export function SoundController() {
|
|||||||
const incomingCallLoop = useRef<AudioBufferSourceNode | null>(null);
|
const incomingCallLoop = useRef<AudioBufferSourceNode | null>(null);
|
||||||
const outgoingCallLoop = 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(() => {
|
useEffect(() => {
|
||||||
if (isInitialMount.current) return;
|
if (isInitialMount.current) return;
|
||||||
if (isWsConnected && !prevIsWsConnected.current) {
|
if (isWsConnected && !prevIsWsConnected.current) {
|
||||||
audioManager.playSound('reconnect');
|
const isInActiveVoice = useVoiceStore.getState().isLiveKitConnected;
|
||||||
|
if (!isInActiveVoice) {
|
||||||
|
audioManager.playSound('reconnect');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
prevIsWsConnected.current = isWsConnected;
|
prevIsWsConnected.current = isWsConnected;
|
||||||
}, [isWsConnected, audioManager]);
|
}, [isWsConnected, audioManager]);
|
||||||
|
|||||||
Reference in New Issue
Block a user