aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/permissionsViewer/utils.ts
diff options
context:
space:
mode:
authorNuckyz <61953774+Nuckyz@users.noreply.github.com>2023-05-19 21:24:56 -0300
committerGitHub <noreply@github.com>2023-05-20 02:24:56 +0200
commitec091a79591cf9619dd589102f5b338827b70ad8 (patch)
treebbb7f56689a4ef399d5ef67cfda68d6f97a2b1db /src/plugins/permissionsViewer/utils.ts
parent89a6c575c9cfe6a6fa72def404220817e008cfea (diff)
downloadVencord-ec091a79591cf9619dd589102f5b338827b70ad8.tar.gz
Vencord-ec091a79591cf9619dd589102f5b338827b70ad8.tar.bz2
Vencord-ec091a79591cf9619dd589102f5b338827b70ad8.zip
Fix SHC broken patches; Sort PermViewer channel overwrites roles (#1166)
Diffstat (limited to 'src/plugins/permissionsViewer/utils.ts')
-rw-r--r--src/plugins/permissionsViewer/utils.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/plugins/permissionsViewer/utils.ts b/src/plugins/permissionsViewer/utils.ts
index b747147..06f293b 100644
--- a/src/plugins/permissionsViewer/utils.ts
+++ b/src/plugins/permissionsViewer/utils.ts
@@ -18,11 +18,12 @@
import { classNameFactory } from "@api/Styles";
import { wordsToTitle } from "@utils/text";
-import { i18n, Parser } from "@webpack/common";
+import { GuildStore, i18n, Parser } from "@webpack/common";
import { Guild, GuildMember, Role } from "discord-types/general";
import type { ReactNode } from "react";
import { PermissionsSortOrder, settings } from ".";
+import { PermissionType } from "./components/RolesAndUsersPermissions";
export const cl = classNameFactory("vc-permviewer-");
@@ -82,3 +83,16 @@ export function sortUserRoles(roles: Role[]) {
return roles;
}
}
+
+export function sortPermissionOverwrites<T extends { id: string; type: number; }>(overwrites: T[], guildId: string) {
+ const guild = GuildStore.getGuild(guildId);
+
+ return overwrites.sort((a, b) => {
+ if (a.type !== PermissionType.Role || b.type !== PermissionType.Role) return 0;
+
+ const roleA = guild.roles[a.id];
+ const roleB = guild.roles[b.id];
+
+ return roleB.position - roleA.position;
+ });
+}