better patch & visual bug fix (#167)

This commit is contained in:
Snek 2022-10-27 18:37:54 +02:00 committed by GitHub
parent ce73a5f172
commit c76e9f5e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -70,19 +70,11 @@ export default definePlugin({
} }
}, },
{ {
// Prevents Discord from trying to fetch message and create a 403 error // inside the onMouseClick handler, we check if the channel is hidden and open the modal if it is
find: "fetchMessages:function", find: ".handleThreadsPopoutClose();",
replacement: { replacement: {
match: /fetchMessages:function\((\w)\){/g, match: /((\w)\.handleThreadsPopoutClose\(\);)/g,
replace: "fetchMessages:function($1){if(Vencord.Plugins.plugins.ShowHiddenChannels.isHiddenChannel($1)) return;" replace: "if(Vencord.Plugins.plugins.ShowHiddenChannels.channelSelected($2?.props?.channel))return;$1"
}
},
{
// 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;"
} }
}, },
{ {
@ -121,9 +113,7 @@ export default definePlugin({
channel._isHiddenChannel = !can(VIEW_CHANNEL, channel) || (channel.type === 2 && !can(CONNECT, channel)); channel._isHiddenChannel = !can(VIEW_CHANNEL, channel) || (channel.type === 2 && !can(CONNECT, channel));
return channel._isHiddenChannel; return channel._isHiddenChannel;
}, },
channelSelected(channelData) { channelSelected(channel) {
if (!channelData) return false;
const channel = ChannelStore.getChannel(channelData.channelId);
if (!channel) return false; if (!channel) return false;
const isHidden = this.isHiddenChannel(channel); const isHidden = this.isHiddenChannel(channel);
// check for type again, otherwise it would show it for hidden stage channels // check for type again, otherwise it would show it for hidden stage channels