From 08174fb27ed02f6c9399e14ca42a10963aa66d6d Mon Sep 17 00:00:00 2001 From: Sam <82487541+example-git@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:01:58 -0500 Subject: [PATCH] fix: vcNarratorCustom user leave voice event filtering bug (#671) * fix(vcNarratorCustom): voice state event filtering is stricter now and has a guard against false positive userleave events * refactor(vcNarratorCustom): remove unused audio toggle functions for self-mute and self-deaf, they're not wired into the menu anyways. I forgot about them cause i just use discords built in mute/deafen sound for my own audio * fix(vcNarratorCustom): ensure voice state snapshot updates only occur if myChanId is defined as an extra guard --- .../vcNarratorCustom/index.tsx | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/equicordplugins/vcNarratorCustom/index.tsx b/src/equicordplugins/vcNarratorCustom/index.tsx index 8d0fef0c9..e1a340bf3 100644 --- a/src/equicordplugins/vcNarratorCustom/index.tsx +++ b/src/equicordplugins/vcNarratorCustom/index.tsx @@ -938,9 +938,19 @@ export default definePlugin({ flux: { async VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) { - const myGuildId = SelectedGuildStore.getGuildId(); - const myChanId = SelectedChannelStore.getVoiceChannelId(); const myId = UserStore.getCurrentUser().id; + const myGuildId = SelectedGuildStore.getGuildId(); + const myVoiceState = VoiceStateStore.getVoiceStateForUser(myId) as VoiceState | undefined; + let myChanId = myVoiceState?.channelId; + if (!myChanId) { + const selectedChanId = SelectedChannelStore.getVoiceChannelId(); + if (selectedChanId) { + const states = VoiceStateStore.getVoiceStatesForChannel?.(selectedChanId) as Record | undefined; + if (states?.[myId]?.channelId === selectedChanId) { + myChanId = selectedChanId; + } + } + } const filterMode = settings.store.stateChangeFilterMode ?? "off"; const filterList = parseStateChangeFilterList(settings.store.stateChangeFilterList); const allowStateChange = (targetId: string, isSelf: boolean) => { @@ -972,6 +982,7 @@ export default definePlugin({ let { oldChannelId } = state; const isMe = userId === myId; + if (!isMe && !myChanId) continue; if (isMe && channelId !== myLastChannelId) { oldChannelId = myLastChannelId; myLastChannelId = channelId ?? undefined; @@ -981,10 +992,12 @@ export default definePlugin({ if (!isMe && !affectsMyChannel) continue; // Keep snapshots in sync for join/leave/move without announcing state changes. - if (oldChannelId !== myChanId && channelId === myChanId) { - voiceStateSnapshot.set(userId, normalizeState(state)); - } else if (oldChannelId === myChanId && channelId !== myChanId) { - voiceStateSnapshot.delete(userId); + if (myChanId) { + if (oldChannelId !== myChanId && channelId === myChanId) { + voiceStateSnapshot.set(userId, normalizeState(state)); + } else if (oldChannelId === myChanId && channelId !== myChanId) { + voiceStateSnapshot.delete(userId); + } } // Join/leave/move announcements (existing behavior) @@ -1047,21 +1060,6 @@ export default definePlugin({ } }, - AUDIO_TOGGLE_SELF_MUTE() { - const chanId = SelectedChannelStore.getVoiceChannelId()!; - const s = VoiceStateStore.getVoiceStateForChannel( - chanId - ) as VoiceState; - if (!s) return; - }, - - AUDIO_TOGGLE_SELF_DEAF() { - const chanId = SelectedChannelStore.getVoiceChannelId()!; - const s = VoiceStateStore.getVoiceStateForChannel( - chanId - ) as VoiceState; - if (!s) return; - }, }, settingsAboutComponent({ tempSettings: s }: { tempSettings?: any; }) {