From f03a88bd789bcbf5cd0f2e0f34c253cb0397256f Mon Sep 17 00:00:00 2001 From: Ed L Date: Sat, 10 Sep 2022 20:20:59 +0100 Subject: [PATCH] fix: move leave/delete server option to the bottom --- src/lib/ContextMenus.tsx | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/lib/ContextMenus.tsx b/src/lib/ContextMenus.tsx index 3298a4aa..16dd239a 100644 --- a/src/lib/ContextMenus.tsx +++ b/src/lib/ContextMenus.tsx @@ -974,6 +974,10 @@ export default function ContextMenus() { } } + // workaround to prevent button duplication + let hideIDButton; + if (sid && server) hideIDButton = true; + if (sid && server) { generateAction( { @@ -1015,15 +1019,28 @@ export default function ContextMenus() { "open_server_settings", ); + // workaround to move this above the delete/leave button + generateAction( + { action: "copy_id", id }, + "copy_sid", + ); + + pushDivider(); if (userId === server.owner) { generateAction( { action: "delete_server", target: server }, "delete_server", + undefined, + undefined, + "var(--error)", ); } else { generateAction( { action: "leave_server", target: server }, "leave_server", + undefined, + undefined, + "var(--error)", ); } } @@ -1035,16 +1052,16 @@ export default function ContextMenus() { }); } - generateAction( - { action: "copy_id", id }, - sid - ? "copy_sid" - : cid - ? "copy_cid" - : message - ? "copy_mid" - : "copy_uid", - ); + if (!hideIDButton) { + generateAction( + { action: "copy_id", id }, + cid + ? "copy_cid" + : message + ? "copy_mid" + : "copy_uid", + ); + } } return elements;