fix: immediately clean up voice state when voice-active socket disconnects

Previously, voice cleanup only happened in finalizeDisconnect after a
5-second grace period, and only when ALL connections closed. If a user
was logged in on multiple devices and closed the one in voice, the
voice state was never cleaned up — creating a permanent ghost in the
channel sidebar.

Now removeConnection checks if the closing socket is the voice-active
one (tracked via voiceWs map) and immediately cleans up voice state,
broadcasts the leave event, and notifies remaining tabs.
This commit is contained in:
Jannis Braun
2026-03-23 14:30:57 +01:00
parent 319832ebc8
commit f90cf91760
2 changed files with 64 additions and 2 deletions
+1 -1
View File
@@ -395,7 +395,7 @@ export type ServerEvent =
| { type: 'voice_space_deafened'; userId: string; channelId: string; spaceId: string; deafened: boolean }
| { type: 'voice_permission_muted'; userId: string; spaceId: string; muted: boolean }
| { type: 'voice_moved'; userId: string; oldChannelId: string; newChannelId: string }
| { type: 'voice_disconnected'; userId: string; channelId: string; reason?: 'displaced' }
| { type: 'voice_disconnected'; userId: string; channelId: string; reason?: 'displaced' | 'session_closed' }
| { type: 'user_updated'; user: User }
| { type: 'member_banned'; spaceId: string; reason: string | null }
| { type: 'category_created'; category: ChannelCategory; spaceId: string }