Files
twenty/front/src/modules/command-menu/hooks/useCommandMenu.ts
Charles Bochet ade5e52e55 Clean and re-organize post table refactoring (#1000)
* Clean and re-organize post table refactoring

* Fix tests
2023-07-30 18:26:32 -07:00

32 lines
861 B
TypeScript

import { useRecoilState } from 'recoil';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
import { isCommandMenuOpenedState } from '../states/isCommandMenuOpenedState';
export function useCommandMenu() {
const [, setIsCommandMenuOpenedState] = useRecoilState(
isCommandMenuOpenedState,
);
const {
setHotkeyScopeAndMemorizePreviousScope,
goBackToPreviousHotkeyScope,
} = usePreviousHotkeyScope();
function openCommandMenu() {
setIsCommandMenuOpenedState(true);
setHotkeyScopeAndMemorizePreviousScope(AppHotkeyScope.CommandMenu);
}
function closeCommandMenu() {
setIsCommandMenuOpenedState(false);
goBackToPreviousHotkeyScope();
}
return {
openCommandMenu,
closeCommandMenu,
};
}