Fix voice status persistence and global visibility across channels
This commit is contained in:
@@ -408,6 +408,18 @@ function handleVoiceJoin(event: Record<string, unknown>, userId: string): void {
|
||||
userId,
|
||||
action: 'join',
|
||||
});
|
||||
|
||||
// Also broadcast current voice status if it exists (persisted during moves)
|
||||
const status = connectionManager.getVoiceUserStatus(userId);
|
||||
if (status) {
|
||||
connectionManager.sendToServer(serverId, {
|
||||
type: 'voice_status_update',
|
||||
userId,
|
||||
channelId,
|
||||
isMuted: status.isMuted,
|
||||
isDeafened: status.isDeafened,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function handleVoiceLeave(userId: string): void {
|
||||
|
||||
@@ -112,11 +112,9 @@ class ConnectionManager {
|
||||
this.voiceStates.delete(channelId);
|
||||
}
|
||||
}
|
||||
this.voiceUserStates.delete(userId);
|
||||
}
|
||||
|
||||
leaveAllVoice(userId: string): string | null {
|
||||
this.voiceUserStates.delete(userId);
|
||||
for (const [channelId, users] of this.voiceStates) {
|
||||
if (users.has(userId)) {
|
||||
users.delete(userId);
|
||||
@@ -560,6 +558,7 @@ export async function registerWebSocket(app: FastifyInstance): Promise<void> {
|
||||
|
||||
// Leave voice if in one
|
||||
const leftChannel = connectionManager.leaveAllVoice(removedUserId);
|
||||
connectionManager.clearVoiceUserStatus(removedUserId);
|
||||
if (leftChannel) {
|
||||
// Get channel's server to broadcast
|
||||
const channel = db.select().from(schema.channels).where(eq(schema.channels.id, leftChannel)).get();
|
||||
|
||||
Reference in New Issue
Block a user