diff --git a/src/app/features/room-nav/RoomNavItem.tsx b/src/app/features/room-nav/RoomNavItem.tsx index ac902136..886301ee 100644 --- a/src/app/features/room-nav/RoomNavItem.tsx +++ b/src/app/features/room-nav/RoomNavItem.tsx @@ -56,7 +56,7 @@ import { RoomNotificationModeSwitcher } from '../../components/RoomNotificationS import { useCallState } from '../../pages/client/call/CallProvider'; import { useRoomNavigate } from '../../hooks/useRoomNavigate'; import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize'; -import { BottomSheetMenu } from '../room/MessageOptionsMenu'; +import { MobileContextMenu } from '../../molecules/mobile-context-menu/MobileContextMenu'; type RoomNavItemMenuProps = { room: Room; @@ -99,7 +99,7 @@ const RoomNavItemMenu = forwardRef( }; return ( - + { - if (isMobile) { - setMobileSheetOpen(true); - } - }, - { - threshold: 400, - cancelOnMovement: true, - } - ); - const handleContextMenu: MouseEventHandler = (evt) => { evt.preventDefault(); @@ -302,148 +290,163 @@ export function RoomNavItem({ setViewedCallRoomId(room.roomId); }; + const handleCloseMenu = () => { + setMenuAnchor(undefined); + setMobileSheetOpen(false); + }; + const optionsVisible = !isMobile && (hover || !!menuAnchor); + const longPressBinder = useLongPress( + () => { + if (isMobile) { + setMobileSheetOpen(true); + } + }, + { + threshold: 400, + cancelOnMovement: true, + } + ); + + const menuContent = ( + + ); + return ( - <> - - - - - {showAvatar ? ( - ( - - {nameInitials(room.name)} - - )} - /> - ) : ( - - )} - - - - {room.name} - - - {!optionsVisible && !unread && !selected && typingMember.length > 0 && ( - - - - )} - {!optionsVisible && unread && ( - - 0} count={unread.total} /> - - )} - {!optionsVisible && notificationMode !== RoomNotificationMode.Unset && ( - + + + + + {showAvatar ? ( + ( + + {nameInitials(room.name)} + + )} + /> + ) : ( + )} + + + + {room.name} + - - {optionsVisible && ( - - setMenuAnchor(undefined), - clickOutsideDeactivates: true, - isKeyForward: (evt) => evt.key === 'ArrowDown', - isKeyBackward: (evt) => evt.key === 'ArrowUp', - escapeDeactivates: stopPropagation, - }} - > - setMenuAnchor(undefined)} - notificationMode={notificationMode} - /> - - } - > - {room.isCallRoom() && ( - - Open chat - - } - > - {(triggerRef) => ( - - - - - - )} - - )} - 0 && ( + + + + )} + {!optionsVisible && unread && ( + + 0} count={unread.total} /> + + )} + {!optionsVisible && notificationMode !== RoomNotificationMode.Unset && ( + + )} + + + {optionsVisible && ( + + setMenuAnchor(undefined), + clickOutsideDeactivates: true, + isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown', + isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp', + escapeDeactivates: stopPropagation, + }} > - - - - - )} - - {isMobile && ( - setMobileSheetOpen(false)}> - setMobileSheetOpen(false)} - notificationMode={notificationMode} - /> - + {menuContent} + + } + > + {room.isCallRoom() && ( + + Open chat + + } + > + {(triggerRef) => ( + + + + + + )} + + )} + + + + + )} - + {isMobile && ( + + {menuContent} + + )} + ); }