1
0
mirror of https://github.com/spacebarchat/client.git synced 2024-11-22 02:12:38 +01:00

context menu item sorting

This commit is contained in:
Puyodead1 2023-08-30 20:36:30 -04:00
parent 77091f9416
commit 7b9c6dc464
No known key found for this signature in database
GPG Key ID: A4FA4FEC0DD353FC
2 changed files with 3 additions and 0 deletions

View File

@ -50,6 +50,7 @@ function ChannelListItem({ guild, channel, isCategory, active }: Props) {
const contextMenu = React.useContext(ContextMenuContext);
const [contextMenuItems, setContextMenuItems] = React.useState<IContextMenuItem[]>([
{
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 });

View File

@ -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 <ContextMenuItem key={index} item={item} close={close} index={index} />;
})}