diff --git a/src/components/ExpandableHeader.css b/src/components/ExpandableHeader.css
deleted file mode 100644
index a556e36b..00000000
--- a/src/components/ExpandableHeader.css
+++ /dev/null
@@ -1,11 +0,0 @@
-.vc-expandableheader-center-flex {
- display: flex;
- place-items: center;
-}
-
-.vc-expandableheader-btn {
- all: unset;
- cursor: pointer;
- width: 24px;
- height: 24px;
-}
diff --git a/src/components/ExpandableHeader.tsx b/src/components/ExpandableHeader.tsx
deleted file mode 100644
index 473dffaa..00000000
--- a/src/components/ExpandableHeader.tsx
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Vencord, a modification for Discord's desktop app
- * Copyright (c) 2023 Vendicated and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
-*/
-
-import "./ExpandableHeader.css";
-
-import { classNameFactory } from "@api/Styles";
-import { Text, Tooltip, useState } from "@webpack/common";
-
-const cl = classNameFactory("vc-expandableheader-");
-
-export interface ExpandableHeaderProps {
- onMoreClick?: () => void;
- moreTooltipText?: string;
- onDropDownClick?: (state: boolean) => void;
- defaultState?: boolean;
- headerText: string;
- children: React.ReactNode;
- buttons?: React.ReactNode[];
- forceOpen?: boolean;
-}
-
-export function ExpandableHeader({
- children,
- onMoreClick,
- buttons,
- moreTooltipText,
- onDropDownClick,
- headerText,
- defaultState = false,
- forceOpen = false,
-}: ExpandableHeaderProps) {
- const [showContent, setShowContent] = useState(defaultState || forceOpen);
-
- return (
- <>
-
-
- {headerText}
-
-
-
- {
- buttons ?? null
- }
-
- {
- onMoreClick && // only show more button if callback is provided
-
- {tooltipProps => (
-
- )}
-
- }
-
-
-
- {tooltipProps => (
-
- )}
-
-
-
- {showContent && children}
- >
- );
-}
diff --git a/src/components/index.ts b/src/components/index.ts
index 38e610fd..2782cb54 100644
--- a/src/components/index.ts
+++ b/src/components/index.ts
@@ -10,7 +10,6 @@ export * from "./CodeBlock";
export * from "./DonateButton";
export { default as ErrorBoundary } from "./ErrorBoundary";
export * from "./ErrorCard";
-export * from "./ExpandableHeader";
export * from "./Flex";
export * from "./Heart";
export * from "./Icons";
diff --git a/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx b/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx
index 32dcaf8d..b1593779 100644
--- a/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx
+++ b/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx
@@ -22,12 +22,12 @@ import { InfoIcon, OwnerCrownIcon } from "@components/Icons";
import { getIntlMessage, getUniqueUsername } from "@utils/discord";
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
import { findByCodeLazy } from "@webpack";
-import { Clipboard, ContextMenuApi, FluxDispatcher, GuildMemberStore, GuildStore, Menu, PermissionsBits, ScrollerThin, Text, Tooltip, useEffect, UserStore, useState, useStateFromStores } from "@webpack/common";
+import { Clipboard, ContextMenuApi, FluxDispatcher, GuildMemberStore, GuildStore, i18n, Menu, PermissionsBits, ScrollerThin, Text, Tooltip, useEffect, useMemo, UserStore, useState, useStateFromStores } from "@webpack/common";
import { UnicodeEmoji } from "@webpack/types";
import type { Guild, Role, User } from "discord-types/general";
import { settings } from "..";
-import { cl, getPermissionDescription, getPermissionString } from "../utils";
+import { cl, getGuildPermissionSpecMap } from "../utils";
import { PermissionAllowedIcon, PermissionDefaultIcon, PermissionDeniedIcon } from "./icons";
export const enum PermissionType {
@@ -56,7 +56,7 @@ function getRoleIconSrc(role: Role) {
}
function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, header }: { permissions: Array; guild: Guild; modalProps: ModalProps; header: string; }) {
- permissions.sort((a, b) => a.type - b.type);
+ const guildPermissionSpecMap = useMemo(() => getGuildPermissionSpecMap(guild), [guild.id]);
useStateFromStores(
[GuildMemberStore],
@@ -65,6 +65,10 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
(old, current) => old.length === current.length
);
+ useEffect(() => {
+ permissions.sort((a, b) => a.type - b.type);
+ }, [permissions]);
+
useEffect(() => {
const usersToRequest = permissions
.filter(p => p.type === PermissionType.User && !GuildMemberStore.isMember(guild.id, p.id!))
@@ -173,7 +177,7 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
- {Object.entries(PermissionsBits).map(([permissionName, bit]) => (
+ {Object.values(PermissionsBits).map(bit => (
{(() => {
@@ -192,9 +196,14 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
return PermissionDefaultIcon();
})()}