fix: clean up cross-instance voice state when switching federated servers
Send explicit voice_leave to the old instance when joining voice on a different origin, preventing stale voice state from showing the user in two channels. Also make WS reconnect voice re-registration origin-aware so remote reconnects properly restore voice state.
This commit is contained in:
@@ -15,6 +15,7 @@ import { getActiveRoom } from '../../hooks/useLiveKit';
|
||||
import { AudioManager } from '../../audio/AudioManager';
|
||||
import { hasPermissionBit, PermissionBits } from '../../utils/permissions';
|
||||
import { parseFederatedUsername, isSelf } from '../../utils/identity';
|
||||
import { joinVoiceChannel } from '../../utils/voice';
|
||||
|
||||
export function ChannelSidebar() {
|
||||
const servers = useServerStore((s) => s.servers);
|
||||
@@ -29,7 +30,6 @@ export function ChannelSidebar() {
|
||||
const members = useServerStore((s) => s.members);
|
||||
const currentVoiceChannelId = useVoiceStore((s) => s.currentVoiceChannelId);
|
||||
const activeDmCall = useVoiceStore((s) => s.activeDmCall);
|
||||
const setCurrentVoiceChannel = useVoiceStore((s) => s.setCurrentVoiceChannel);
|
||||
const isMuted = useVoiceStore((s) => s.isMuted);
|
||||
const isDeafened = useVoiceStore((s) => s.isDeafened);
|
||||
const toggleMic = useVoiceStore((s) => s.toggleMic);
|
||||
@@ -104,8 +104,7 @@ export function ChannelSidebar() {
|
||||
navigate(`/channels/${currentServerId}/${channelId}`);
|
||||
return;
|
||||
}
|
||||
setCurrentVoiceChannel(channelId);
|
||||
wsSend({ type: 'voice_join', channelId }, getChannelOrigin(channelId));
|
||||
joinVoiceChannel(channelId);
|
||||
navigate(`/channels/${currentServerId}/${channelId}`);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
||||
import { useServerStore, getChannelOrigin } from '../../stores/serverStore';
|
||||
import { useServerStore } from '../../stores/serverStore';
|
||||
import { useChatStore } from '../../stores/chatStore';
|
||||
import { useUIStore } from '../../stores/uiStore';
|
||||
import { useAuthStore } from '../../stores/authStore';
|
||||
@@ -15,6 +15,7 @@ import { useVoiceStore } from '../../stores/voiceStore';
|
||||
import { wsSend } from '../../hooks/useWebSocket';
|
||||
import { MemberListToggleButton } from './MemberListToggleButton';
|
||||
import { isSelf } from '../../utils/identity';
|
||||
import { joinVoiceChannel } from '../../utils/voice';
|
||||
|
||||
export function MainContent() {
|
||||
// 1. ALL HOOKS AT THE TOP
|
||||
@@ -258,10 +259,7 @@ export function MainContent() {
|
||||
<p className="text-txt-tertiary text-[15px]">No one is currently in this voice channel.</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
useVoiceStore.getState().setCurrentVoiceChannel(currentChannelId);
|
||||
wsSend({ type: 'voice_join', channelId: currentChannelId }, getChannelOrigin(currentChannelId));
|
||||
}}
|
||||
onClick={() => joinVoiceChannel(currentChannelId)}
|
||||
className="relative z-10 px-8 py-3 bg-accent-primary hover:bg-accent-primary-hover text-white font-semibold rounded-full transition-all text-[15px] shadow-[0_4px_20px_rgba(124,108,246,0.3)]"
|
||||
>
|
||||
Join Voice
|
||||
|
||||
Reference in New Issue
Block a user