From c76e9f5e3d5a282a0e723593fcdc4cf996d419be Mon Sep 17 00:00:00 2001 From: Snek <107999380+sneksnake@users.noreply.github.com> Date: Thu, 27 Oct 2022 18:37:54 +0200 Subject: better patch & visual bug fix (#167) --- src/plugins/showHiddenChannels.tsx | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/plugins/showHiddenChannels.tsx') diff --git a/src/plugins/showHiddenChannels.tsx b/src/plugins/showHiddenChannels.tsx index 0650cc4..84f7c3e 100644 --- a/src/plugins/showHiddenChannels.tsx +++ b/src/plugins/showHiddenChannels.tsx @@ -70,19 +70,11 @@ export default definePlugin({ } }, { - // Prevents Discord from trying to fetch message and create a 403 error - find: "fetchMessages:function", + // inside the onMouseClick handler, we check if the channel is hidden and open the modal if it is + find: ".handleThreadsPopoutClose();", replacement: { - match: /fetchMessages:function\((\w)\){/g, - replace: "fetchMessages:function($1){if(Vencord.Plugins.plugins.ShowHiddenChannels.isHiddenChannel($1)) return;" - } - }, - { - // Don't switch to the channel if it's hidden, but show a modal instead - find: ".selectGuild(", - replacement: { - match: /(function \w+\(\w\)\{var (\w)=\w+\(\w\);)/g, - replace: "$1if(Vencord.Plugins.plugins.ShowHiddenChannels.channelSelected($2?.params))return;" + match: /((\w)\.handleThreadsPopoutClose\(\);)/g, + replace: "if(Vencord.Plugins.plugins.ShowHiddenChannels.channelSelected($2?.props?.channel))return;$1" } }, { @@ -121,9 +113,7 @@ export default definePlugin({ channel._isHiddenChannel = !can(VIEW_CHANNEL, channel) || (channel.type === 2 && !can(CONNECT, channel)); return channel._isHiddenChannel; }, - channelSelected(channelData) { - if (!channelData) return false; - const channel = ChannelStore.getChannel(channelData.channelId); + channelSelected(channel) { if (!channel) return false; const isHidden = this.isHiddenChannel(channel); // check for type again, otherwise it would show it for hidden stage channels -- cgit