mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Migrate react-contextmenu menus to axo menus
Co-authored-by: Fedor Indutny <indutny@signal.org>
This commit is contained in:
@@ -8,7 +8,6 @@ import * as KeyboardLayout from '../services/keyboardLayout.dom.js';
|
||||
import { getHasPanelOpen } from '../state/selectors/conversations.dom.js';
|
||||
import { isInFullScreenCall } from '../state/selectors/calling.std.js';
|
||||
import { isShowingAnyModal } from '../state/selectors/globalModals.std.js';
|
||||
import type { ContextMenuTriggerType } from '../components/conversation/MessageContextMenu.dom.js';
|
||||
|
||||
const { get } = lodash;
|
||||
|
||||
@@ -295,39 +294,6 @@ export function useToggleReactionPicker(
|
||||
);
|
||||
}
|
||||
|
||||
export function useOpenContextMenu(
|
||||
openContextMenu: ContextMenuTriggerType['handleContextClick'] | undefined
|
||||
): KeyboardShortcutHandlerType {
|
||||
const hasOverlay = useHasAnyOverlay();
|
||||
|
||||
return useCallback(
|
||||
ev => {
|
||||
if (hasOverlay) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { shiftKey } = ev;
|
||||
const key = KeyboardLayout.lookup(ev);
|
||||
|
||||
const isMacOS = get(window, 'platform') === 'darwin';
|
||||
|
||||
if (
|
||||
(!isMacOS && shiftKey && key === 'F10') ||
|
||||
(isMacOS && isCmdOrCtrl(ev) && key === 'F12')
|
||||
) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
openContextMenu?.(new MouseEvent('click'));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
[hasOverlay, openContextMenu]
|
||||
);
|
||||
}
|
||||
|
||||
export function useEditLastMessageSent(
|
||||
maybeEditMessage: () => boolean
|
||||
): KeyboardShortcutHandlerType {
|
||||
|
||||
Reference in New Issue
Block a user