From c5a3bae516638cbe3a34f1b5acca5c4f85894823 Mon Sep 17 00:00:00 2001 From: Supertiger Date: Wed, 11 Dec 2024 09:36:56 +0000 Subject: [PATCH] fix nickname not showing --- .../member-context-menu/MemberContextMenu.tsx | 13 ++++++------- src/components/ui/context-menu/ContextMenu.tsx | 8 ++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/member-context-menu/MemberContextMenu.tsx b/src/components/member-context-menu/MemberContextMenu.tsx index a3803b14..f5cc437e 100644 --- a/src/components/member-context-menu/MemberContextMenu.tsx +++ b/src/components/member-context-menu/MemberContextMenu.tsx @@ -84,13 +84,11 @@ export default function MemberContextMenu(props: Props) { const clickedOnMyself = props.userId === account.user()?.id; const items: any = []; - const hasAdminPermission = selfMember()?.hasPermission( - ROLE_PERMISSIONS.ADMIN - ); - const hasNicknamePermission = selfMember()?.hasPermission( - ROLE_PERMISSIONS.NICKNAME_MEMBER - ); - if (hasNicknamePermission && (hasAdminPermission || clickedOnMyself)) { + const hasNicknamePermission = + selfMember()?.hasPermission(ROLE_PERMISSIONS.NICKNAME_MEMBER) || + clickedOnMyself; + + if (hasNicknamePermission) { items.push(nickname); } const hasManageRolePermission = selfMember()?.hasPermission( @@ -122,6 +120,7 @@ export default function MemberContextMenu(props: Props) { const createArr = []; + hasNicknamePermission && createArr.push(nickname); if (hasBanPermission || hasKickPermission) { createArr.push(separator); } diff --git a/src/components/ui/context-menu/ContextMenu.tsx b/src/components/ui/context-menu/ContextMenu.tsx index 81657817..1e4297b0 100644 --- a/src/components/ui/context-menu/ContextMenu.tsx +++ b/src/components/ui/context-menu/ContextMenu.tsx @@ -52,12 +52,16 @@ export default function ContextMenu(props: ContextMenuProps) { const [pos, setPos] = createSignal({ top: "0", left: "0" }); const { isMobileWidth, hasFocus } = useWindowProperties(); - const [items, setItems] = createStore(props.items); + const [items, setItems] = createStore([]); const { height, width } = useResizeObserver(contextMenuEl); createEffect(() => { - setItems(reconcile(props.items)); + if (props.position) { + setItems(reconcile(props.items)); + } else { + setItems([]); + } }); const handleOutsideClick = (e: any) => {