From ec091a79591cf9619dd589102f5b338827b70ad8 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 19 May 2023 21:24:56 -0300 Subject: Fix SHC broken patches; Sort PermViewer channel overwrites roles (#1166) --- src/plugins/permissionsViewer/utils.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/plugins/permissionsViewer/utils.ts') 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(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; + }); +} -- cgit