1
0
Fork 0

Add more conditions for binding longpress

Should be same condition as contextmenu
This commit is contained in:
Lim Chee Aun 2023-11-02 08:00:00 +08:00
parent 030728bc93
commit bf7acb6eab

View file

@ -795,13 +795,16 @@ function Status({
const contextMenuRef = useRef();
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
const [contextMenuProps, setContextMenuProps] = useState({});
const showContextMenu = !isSizeLarge && !previewMode && !_deleted && !quoted;
const isIOS =
window.ontouchstart !== undefined &&
/iPad|iPhone|iPod/.test(navigator.userAgent);
// Only iOS/iPadOS browsers don't support contextmenu
// Some comments report iPadOS might support contextmenu if a mouse is connected
const bindLongPressContext = useLongPress(
isIOS
isIOS && showContextMenu
? (e) => {
if (e.pointerType === 'mouse') return;
// There's 'pen' too, but not sure if contextmenu event would trigger from a pen
@ -829,8 +832,6 @@ function Status({
},
);
const showContextMenu = size !== 'l' && !previewMode && !_deleted && !quoted;
const hotkeysEnabled = !readOnly && !previewMode;
const rRef = useHotkeys('r', replyStatus, {
enabled: hotkeysEnabled,