Fix KeyboardShortcut menu, person upload picture (#2669)

* Fix KeyboardShortcut menu, person upload picture

* Fixes
This commit is contained in:
Charles Bochet
2023-11-23 13:44:54 +01:00
committed by GitHub
parent 9c4f402102
commit 9dabe44d0f
16 changed files with 168 additions and 35 deletions

View File

@ -9,7 +9,9 @@ import { isCommandMenuOpenedState } from '../states/isCommandMenuOpenedState';
import { Command } from '../types/Command';
export const useCommandMenu = () => {
const [, setIsCommandMenuOpened] = useRecoilState(isCommandMenuOpenedState);
const [isCommandMenuOpened, setIsCommandMenuOpened] = useRecoilState(
isCommandMenuOpenedState,
);
const setCommands = useSetRecoilState(commandMenuCommandsState);
const {
setHotkeyScopeAndMemorizePreviousScope,
@ -26,6 +28,14 @@ export const useCommandMenu = () => {
goBackToPreviousHotkeyScope();
};
const toggleCommandMenu = () => {
if (isCommandMenuOpened) {
closeCommandMenu();
} else {
openCommandMenu();
}
};
const addToCommandMenu = (addCommand: Command[]) => {
setCommands((prev) => [...prev, ...addCommand]);
};
@ -37,6 +47,7 @@ export const useCommandMenu = () => {
return {
openCommandMenu,
closeCommandMenu,
toggleCommandMenu,
addToCommandMenu,
setToIntitialCommandMenu,
};