From b10fbd0ddd9603244426975b39d49171a373a530 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sat, 13 Sep 2025 02:53:58 -0400 Subject: [PATCH] NewGuildSettings: Fix undoing collapsed channels --- .../discord-types/src/common/Channel.d.ts | 1 + src/plugins/newGuildSettings/index.tsx | 22 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/discord-types/src/common/Channel.d.ts b/packages/discord-types/src/common/Channel.d.ts index 7ad5ce535..8742c9c43 100644 --- a/packages/discord-types/src/common/Channel.d.ts +++ b/packages/discord-types/src/common/Channel.d.ts @@ -71,6 +71,7 @@ export class Channel extends DiscordRecord { isGroupDM(): boolean; isGuildStageVoice(): boolean; isGuildVoice(): boolean; + isGuildVocal(): boolean; isListenModeCapable(): boolean; isManaged(): boolean; isMultiUserDM(): boolean; diff --git a/src/plugins/newGuildSettings/index.tsx b/src/plugins/newGuildSettings/index.tsx index c09f3496a..ea14b24fa 100644 --- a/src/plugins/newGuildSettings/index.tsx +++ b/src/plugins/newGuildSettings/index.tsx @@ -25,8 +25,8 @@ import { CogWheel } from "@components/Icons"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { Guild } from "@vencord/discord-types"; -import { findByCodeLazy, findByPropsLazy, mapMangledModuleLazy } from "@webpack"; -import { FluxDispatcher, GuildChannelStore, Menu } from "@webpack/common"; +import { findByCodeLazy, findByPropsLazy, findStoreLazy, mapMangledModuleLazy } from "@webpack"; +import { ChannelStore, Menu } from "@webpack/common"; const { updateGuildNotificationSettings } = findByPropsLazy("updateGuildNotificationSettings"); const { toggleShowAllChannels } = mapMangledModuleLazy(".onboardExistingMember(", { @@ -36,6 +36,8 @@ const { toggleShowAllChannels } = mapMangledModuleLazy(".onboardExistingMember(" } }); const isOptInEnabledForGuild = findByCodeLazy(".COMMUNITY)||", ".isOptInEnabled("); +const CollapsedVoiceChannelStore = findStoreLazy("CollapsedVoiceChannelStore"); +const collapsedChannels = findByPropsLazy("toggleCollapseGuild"); const settings = definePluginSettings({ guild: { @@ -108,18 +110,10 @@ function applyVoiceNameHidingToGuild(guildId: string) { if (!settings.store.voiceChannels) return; try { - const channels = GuildChannelStore.getChannels(guildId); - if (!channels?.VOCAL) return; - - channels.VOCAL.forEach(({ channel }: { channel: { id: string; type: number; }; }) => { - if (channel.type === 2) { - FluxDispatcher.dispatch({ - type: "CHANNEL_COLLAPSE", - channelId: channel.id, - collapsed: true - }); - } - }); + ChannelStore.getChannelIds(guildId).filter(channelId => { + const channel = ChannelStore.getChannel(channelId); + return channel.isGuildVocal() && !CollapsedVoiceChannelStore.isCollapsed(channelId); + }).forEach(id => collapsedChannels.update(id)); } catch (error) { console.warn("[NewGuildSettings] Error applying voice name hiding:", error); }