From 7b9c6dc46482b355a16d1656b5af03a5a88b3f01 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Wed, 30 Aug 2023 20:36:30 -0400 Subject: [PATCH] context menu item sorting --- src/components/ChannelListItem.tsx | 2 ++ src/components/ContextMenu.tsx | 1 + 2 files changed, 3 insertions(+) diff --git a/src/components/ChannelListItem.tsx b/src/components/ChannelListItem.tsx index 229bfa7..c212f5a 100644 --- a/src/components/ChannelListItem.tsx +++ b/src/components/ChannelListItem.tsx @@ -50,6 +50,7 @@ function ChannelListItem({ guild, channel, isCategory, active }: Props) { const contextMenu = React.useContext(ContextMenuContext); const [contextMenuItems, setContextMenuItems] = React.useState([ { + index: 1, label: "Copy Channel ID", onClick: () => { navigator.clipboard.writeText(channel.id); @@ -59,6 +60,7 @@ function ChannelListItem({ guild, channel, isCategory, active }: Props) { }, }, { + index: 0, label: "Create Channel Invite", onClick: () => { openModal(CreateInviteModal, { guild_id: guild.id, channel_id: channel.id }); diff --git a/src/components/ContextMenu.tsx b/src/components/ContextMenu.tsx index a7bd74f..9ba84e3 100644 --- a/src/components/ContextMenu.tsx +++ b/src/components/ContextMenu.tsx @@ -44,6 +44,7 @@ function ContextMenu({ position, close, items, style }: Props) { > {items .filter((a) => a.visible !== false) + .sort((a, b) => (a.index ?? 0) - (b.index ?? 0)) .map((item, index) => { return ; })}