aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/permissionsViewer/index.tsx31
-rw-r--r--src/plugins/permissionsViewer/styles.css3
-rw-r--r--src/plugins/searchReply.tsx2
3 files changed, 23 insertions, 13 deletions
diff --git a/src/plugins/permissionsViewer/index.tsx b/src/plugins/permissionsViewer/index.tsx
index 793105a..208fef3 100644
--- a/src/plugins/permissionsViewer/index.tsx
+++ b/src/plugins/permissionsViewer/index.tsx
@@ -57,6 +57,8 @@ export const settings = definePluginSettings({
});
function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
+ if (type === MenuItemParentType.User && !GuildMemberStore.isMember(guildId, id!)) return null;
+
return (
<Menu.MenuItem
id="perm-viewer-permissions"
@@ -122,25 +124,32 @@ function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
);
}
-function makeContextMenuPatch(childId: string, type?: MenuItemParentType): NavContextMenuPatchCallback {
+function makeContextMenuPatch(childId: string | string[], type?: MenuItemParentType): NavContextMenuPatchCallback {
return (children, props) => () => {
if (!props) return children;
const group = findGroupChildrenByChildId(childId, children);
- if (group) {
+ const item = (() => {
switch (type) {
case MenuItemParentType.User:
- group.push(MenuItem(props.guildId, props.user.id, type));
- break;
+ return MenuItem(props.guildId, props.user.id, type);
case MenuItemParentType.Channel:
- group.push(MenuItem(props.guild.id, props.channel.id, type));
- break;
+ return MenuItem(props.guild.id, props.channel.id, type);
case MenuItemParentType.Guild:
- group.push(MenuItem(props.guild.id));
- break;
+ return MenuItem(props.guild.id);
+ default:
+ return null;
}
- }
+ })();
+
+ if (item == null) return;
+
+ if (group)
+ group.push(item);
+ else if (childId === "roles" && props.guildId)
+ // "roles" may not be present due to the member not having any roles. In that case, add it above "Copy ID"
+ children.splice(-1, 0, <Menu.MenuGroup>{item}</Menu.MenuGroup>);
};
}
@@ -160,10 +169,10 @@ export default definePlugin({
}
],
- UserPermissions: (guild: Guild, guildMember: GuildMember) => <UserPermissions guild={guild} guildMember={guildMember} />,
+ UserPermissions: (guild: Guild, guildMember?: GuildMember) => !!guildMember && <UserPermissions guild={guild} guildMember={guildMember} />,
userContextMenuPatch: makeContextMenuPatch("roles", MenuItemParentType.User),
- channelContextMenuPatch: makeContextMenuPatch("mute-channel", MenuItemParentType.Channel),
+ channelContextMenuPatch: makeContextMenuPatch(["mute-channel", "unmute-channel"], MenuItemParentType.Channel),
guildContextMenuPatch: makeContextMenuPatch("privacy", MenuItemParentType.Guild),
start() {
diff --git a/src/plugins/permissionsViewer/styles.css b/src/plugins/permissionsViewer/styles.css
index 6d6c137..08e5e1c 100644
--- a/src/plugins/permissionsViewer/styles.css
+++ b/src/plugins/permissionsViewer/styles.css
@@ -59,7 +59,7 @@
align-items: center;
padding: 8px 5px;
cursor: pointer;
- width: 165px;
+ width: 230px;
}
.vc-permviewer-perms-list-item > div {
@@ -121,6 +121,7 @@
position: absolute;
right: 0;
scale: 0.9;
+ transition: color ease-in 0.1s;
}
.vc-permviewer-perms-perms-item .vc-info-icon:hover {
diff --git a/src/plugins/searchReply.tsx b/src/plugins/searchReply.tsx
index fe6348b..9e53436 100644
--- a/src/plugins/searchReply.tsx
+++ b/src/plugins/searchReply.tsx
@@ -38,7 +38,7 @@ const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { messag
// dms and group chats
const dmGroup = findGroupChildrenByChildId("pin", children);
if (dmGroup && !dmGroup.some(child => child?.props?.id === "reply")) {
- const pinIndex = dmGroup.findIndex(c => c.props.id === "pin");
+ const pinIndex = dmGroup.findIndex(c => c?.props.id === "pin");
return dmGroup.splice(pinIndex + 1, 0, (
<Menu.MenuItem
id="reply"