Match logic for context menu and long press

This commit is contained in:
Lim Chee Aun 2023-04-26 10:35:26 +08:00
parent 6f430ca0f5
commit 4001e1c47a

View file

@ -679,6 +679,8 @@ function Status({
}, },
); );
const showContextMenu = size !== 'l' && !previewMode && !_deleted;
return ( return (
<article <article
ref={statusRef} ref={statusRef}
@ -694,10 +696,8 @@ function Status({
} ${_deleted ? 'status-deleted' : ''} ${quoted ? 'status-card' : ''}`} } ${_deleted ? 'status-deleted' : ''} ${quoted ? 'status-card' : ''}`}
onMouseEnter={debugHover} onMouseEnter={debugHover}
onContextMenu={(e) => { onContextMenu={(e) => {
if (size === 'l') return; if (!showContextMenu) return;
if (e.metaKey) return; if (e.metaKey) return;
if (previewMode) return;
if (_deleted) return;
// console.log('context menu', e); // console.log('context menu', e);
const link = e.target.closest('a'); const link = e.target.closest('a');
if (link && /^https?:\/\//.test(link.getAttribute('href'))) return; if (link && /^https?:\/\//.test(link.getAttribute('href'))) return;
@ -708,9 +708,9 @@ function Status({
}); });
setIsContextMenuOpen(true); setIsContextMenuOpen(true);
}} }}
{...bindLongPress()} {...(showContextMenu ? bindLongPress() : {})}
> >
{size !== 'l' && ( {showContextMenu && (
<ControlledMenu <ControlledMenu
ref={contextMenuRef} ref={contextMenuRef}
state={isContextMenuOpen ? 'open' : undefined} state={isContextMenuOpen ? 'open' : undefined}