Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Vendicated/Vencord
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 26, 2024
2 parents 24c7b68 + 60b7766 commit f03dff0
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 254 deletions.
4 changes: 3 additions & 1 deletion src/api/ChatButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export interface ChatBarButtonProps {
tooltip: string;
onClick: MouseEventHandler<HTMLButtonElement>;
onContextMenu?: MouseEventHandler<HTMLButtonElement>;
buttonProps?: Omit<HTMLProps<HTMLButtonElement>, "size" | "onClick" | "onContextMenu">;
onAuxClick?: MouseEventHandler<HTMLButtonElement>;
buttonProps?: Omit<HTMLProps<HTMLButtonElement>, "size" | "onClick" | "onContextMenu" | "onAuxClick">;
}
export const ChatBarButton = ErrorBoundary.wrap((props: ChatBarButtonProps) => {
return (
Expand All @@ -115,6 +116,7 @@ export const ChatBarButton = ErrorBoundary.wrap((props: ChatBarButtonProps) => {
innerClassName={`${ButtonWrapperClasses.button} ${ChannelTextAreaClasses?.button}`}
onClick={props.onClick}
onContextMenu={props.onContextMenu}
onAuxClick={props.onAuxClick}
{...props.buttonProps}
>
<div className={ButtonWrapperClasses.buttonWrapper}>
Expand Down
11 changes: 0 additions & 11 deletions src/components/ExpandableHeader.css

This file was deleted.

121 changes: 0 additions & 121 deletions src/components/ExpandableHeader.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
34 changes: 20 additions & 14 deletions src/plugins/betterFolders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default definePlugin({
},
// If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children
{
match: /lastTargetNode:\i\[\i\.length-1\].+?Fragment.+?\]}\)\]/,
match: /lastTargetNode:\i\[\i\.length-1\].+?}\)\](?=}\))/,
replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0]?.isBetterFolders))"
},
// If we are rendering the Better Folders sidebar, we filter out everything but the scroller for the guild list from the GuildsBar Tree children
Expand Down Expand Up @@ -275,24 +275,30 @@ export default definePlugin({
},

makeGuildsBarGuildListFilter(isBetterFolders: boolean) {
return child => {
if (isBetterFolders) {
try {
return child?.props?.["aria-label"] === getIntlMessage("SERVERS");
} catch (e) {
console.error(e);
}
}
return true;
};
return child => {
if (!isBetterFolders) return true;

try {
return child?.props?.["aria-label"] === getIntlMessage("SERVERS");
} catch (e) {
console.error(e);
}

return true;
};
},

makeGuildsBarTreeFilter(isBetterFolders: boolean) {
return child => {
if (isBetterFolders) {
return child?.props?.onScroll != null;
if (!isBetterFolders) return true;

if (child?.props?.className?.includes("itemsContainer") && child.props.children != null) {
// Filter out everything but the scroller for the guild list
child.props.children = child.props.children.filter(child => child?.props?.onScroll != null);
return true;
}
return true;

return false;
};
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -56,7 +56,7 @@ function getRoleIconSrc(role: Role) {
}

function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, header }: { permissions: Array<RoleOrUserPermission>; guild: Guild; modalProps: ModalProps; header: string; }) {
permissions.sort((a, b) => a.type - b.type);
const guildPermissionSpecMap = useMemo(() => getGuildPermissionSpecMap(guild), [guild.id]);

useStateFromStores(
[GuildMemberStore],
Expand All @@ -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!))
Expand Down Expand Up @@ -173,7 +177,7 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
</ScrollerThin>
<div className={cl("modal-divider")} />
<ScrollerThin className={cl("modal-perms")} orientation="auto">
{Object.entries(PermissionsBits).map(([permissionName, bit]) => (
{Object.values(PermissionsBits).map(bit => (
<div className={cl("modal-perms-item")}>
<div className={cl("modal-perms-item-icon")}>
{(() => {
Expand All @@ -192,9 +196,14 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
return PermissionDefaultIcon();
})()}
</div>
<Text variant="text-md/normal">{getPermissionString(permissionName)}</Text>
<Text variant="text-md/normal">{guildPermissionSpecMap[String(bit)].title}</Text>

<Tooltip text={getPermissionDescription(permissionName) || "No Description"}>
<Tooltip text={
(() => {
const { description } = guildPermissionSpecMap[String(bit)];
return typeof description === "function" ? i18n.intl.format(description, {}) : description;
})()
}>
{props => <InfoIcon {...props} />}
</Tooltip>
</div>
Expand Down
Loading

0 comments on commit f03dff0

Please sign in to comment.