aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/showHiddenChannels/index.tsx
diff options
context:
space:
mode:
authorNuckyz <61953774+Nuckyz@users.noreply.github.com>2023-04-15 00:02:08 -0300
committerGitHub <noreply@github.com>2023-04-15 05:02:08 +0200
commit336c7bdd5e7324b35596200a50ca1d3da3d7ce83 (patch)
treec43608d9d67141b0b885295d1d297e427a9a4571 /src/plugins/showHiddenChannels/index.tsx
parent88ad4f1b0597a06695aae4166fb8ac1024f31c4c (diff)
downloadVencord-336c7bdd5e7324b35596200a50ca1d3da3d7ce83.tar.gz
Vencord-336c7bdd5e7324b35596200a50ca1d3da3d7ce83.tar.bz2
Vencord-336c7bdd5e7324b35596200a50ca1d3da3d7ce83.zip
SHC: Fix emoji rendering & allowed users/roles edge cases (#895)
Co-authored-by: V <vendicated@riseup.net>
Diffstat (limited to 'src/plugins/showHiddenChannels/index.tsx')
-rw-r--r--src/plugins/showHiddenChannels/index.tsx33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx
index d69085d..5cdc05b 100644
--- a/src/plugins/showHiddenChannels/index.tsx
+++ b/src/plugins/showHiddenChannels/index.tsx
@@ -25,7 +25,7 @@ import { canonicalizeMatch } from "@utils/patches";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { ChannelStore, PermissionStore, Tooltip } from "@webpack/common";
-import { Channel } from "discord-types/general";
+import type { Channel, Role } from "discord-types/general";
import HiddenChannelLockScreen, { setChannelBeginHeaderComponent } from "./components/HiddenChannelLockScreen";
@@ -253,11 +253,23 @@ export default definePlugin({
replace: (m, channel, permCheck) => `${m}!Vencord.Webpack.Common.PermissionStore.can(${CONNECT}n,${channel})?${permCheck}CONNECT):`
},
{
+ // Include the @everyone role in the allowed roles list for Hidden Channels
+ match: /sortBy.{0,100}?return (?<=var (\i)=\i\.channel.+?)(?=\i\.id)/,
+ replace: (m, channel) => `${m}$self.isHiddenChannel(${channel})?true:`
+ },
+ {
+ // If the @everyone role has the required permissions, make the array only contain it
+ match: /computePermissionsForRoles.+?.value\(\)(?<=var (\i)=\i\.channel.+?)/,
+ replace: (m, channel) => `${m}.reduce(...$self.makeAllowedRolesReduce(${channel}.guild_id))`
+ },
+ {
// Patch the header to only return allowed users and roles if it's a hidden channel or locked channel (Like when it's used on the HiddenChannelLockScreen)
match: /MANAGE_ROLES.{0,60}?return(?=\(.+?(\(0,\i\.jsxs\)\("div",{className:\i\(\)\.members.+?guildId:(\i)\.guild_id.+?roleColor.+?]}\)))/,
replace: (m, component, channel) => {
// Export the channel for the users allowed component patch
component = component.replace(canonicalizeMatch(/(?<=users:\i)/), `,channel:${channel}`);
+ // Always render the component for multiple allowed users
+ component = component.replace(canonicalizeMatch(/1!==\i\.length/), "true");
return `${m} $self.isHiddenChannel(${channel},true)?${component}:`;
}
@@ -311,6 +323,11 @@ export default definePlugin({
// Disable useless components for the HiddenChannelLockScreen of voice channels
match: /(?:{|,)render(?!Header|ExternalHeader).{0,30}?:(?<=renderContent=function.+?)(?!void)/g,
replace: "$&!this.props.inCall&&$self.isHiddenChannel(this.props.channel,true)?null:"
+ },
+ {
+ // Disable bad CSS class which mess up hidden voice channels styling
+ match: /callContainer,(?<=(\i)=\i\.channel.+?\(\)\.callContainer,)/,
+ replace: (m, channel) => `${m}$self.isHiddenChannel(${channel},true)?"":`
}
]
},
@@ -426,6 +443,20 @@ export default definePlugin({
return res;
},
+ makeAllowedRolesReduce(guildId: string) {
+ return [
+ (prev: Array<Role>, _: Role, index: number, originalArray: Array<Role>) => {
+ if (index !== 0) return prev;
+
+ const everyoneRole = originalArray.find(role => role.id === guildId);
+
+ if (everyoneRole) return [everyoneRole];
+ return originalArray;
+ },
+ [] as Array<Role>
+ ];
+ },
+
HiddenChannelLockScreen: (channel: any) => <HiddenChannelLockScreen channel={channel} />,
LockIcon: () => (