ShowHiddenChannels: Fix showing allowed roles
This commit is contained in:
parent
74d78d89ed
commit
fe2ed0776f
1 changed files with 14 additions and 12 deletions
|
|
@ -23,7 +23,6 @@ import { classNameFactory } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { canonicalizeMatch } from "@utils/patches";
|
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import type { Channel, Role } from "@vencord/discord-types";
|
import type { Channel, Role } from "@vencord/discord-types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
|
@ -302,15 +301,18 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// 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)
|
// 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,90}?return(?=\(.+?(\(0,\i\.jsxs\)\("div",{className:\i\.members.+?guildId:(\i)\.guild_id.+?roleColor.+?\]}\)))/,
|
match: /\.members.+?\]}\),(?<=channel:(\i).+?)/,
|
||||||
replace: (m, component, channel) => {
|
replace: (m, channel) => `${m}$self.isHiddenChannel(${channel},true)?null:`
|
||||||
// Export the channel for the users allowed component patch
|
},
|
||||||
component = component.replace(canonicalizeMatch(/(?<=users:\i)/), `,shcChannel:${channel}`);
|
{
|
||||||
// Always render the component for multiple allowed users
|
// Export the channel for the users allowed component patch
|
||||||
component = component.replace(canonicalizeMatch(/1!==\i\.length/), "true");
|
match: /maxUsers:\i,users:\i(?<=channel:(\i).+?)/,
|
||||||
|
replace: (m, channel) => `${m},shcChannel:${channel}`
|
||||||
return `${m} $self.isHiddenChannel(${channel},true)?${component}:`;
|
},
|
||||||
}
|
{
|
||||||
|
// Always render the component for multiple allowed users
|
||||||
|
match: /1!==\i\.length(?=\|\|)/,
|
||||||
|
replace: "true"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -319,8 +321,8 @@ export default definePlugin({
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
// Create a variable for the channel prop
|
// Create a variable for the channel prop
|
||||||
match: /(function \i\(\i\)\{)([^}]+?hideOverflowCount)/,
|
match: /let{users:\i,maxUsers:\i,/,
|
||||||
replace: "$1let {shcChannel}=arguments[0];$2"
|
replace: "let{shcChannel}=arguments[0];$&"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Make Discord always render the plus button if the component is used inside the HiddenChannelLockScreen
|
// Make Discord always render the plus button if the component is used inside the HiddenChannelLockScreen
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue