Refactor hotkyes in its own lib folder (#660)

* Refactor hotkyes in its own lib folder

* Lint

* Fix PR comments

* rename hotkeysScope into hotkeyScope
This commit is contained in:
Charles Bochet
2023-07-14 12:27:26 -07:00
committed by GitHub
parent 7bcea343e2
commit e93a96b3b1
71 changed files with 398 additions and 386 deletions

View File

@@ -1,8 +1,8 @@
import { useRecoilState } from 'recoil';
import { usePreviousHotkeysScope } from '@/hotkeys/hooks/internal/usePreviousHotkeysScope';
import { useScopedHotkeys } from '@/hotkeys/hooks/useScopedHotkeys';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { usePreviousHotkeyScope } from '@/lib/hotkeys/hooks/usePreviousHotkeyScope';
import { useScopedHotkeys } from '@/lib/hotkeys/hooks/useScopedHotkeys';
import { AppHotkeyScope } from '@/lib/hotkeys/types/AppHotkeyScope';
import { isCommandMenuOpenedState } from '../states/isCommandMenuOpened';
@@ -23,22 +23,22 @@ export function CommandMenu() {
() => {
handleOpenChange(!open);
},
InternalHotkeysScope.CommandMenu,
AppHotkeyScope.CommandMenu,
[setOpen, open, handleOpenChange],
);
const {
setHotkeysScopeAndMemorizePreviousScope,
goBackToPreviousHotkeysScope,
} = usePreviousHotkeysScope();
setHotkeyScopeAndMemorizePreviousScope,
goBackToPreviousHotkeyScope,
} = usePreviousHotkeyScope();
function handleOpenChange(newOpenState: boolean) {
if (newOpenState) {
setOpen(true);
setHotkeysScopeAndMemorizePreviousScope(InternalHotkeysScope.CommandMenu);
setHotkeyScopeAndMemorizePreviousScope(AppHotkeyScope.CommandMenu);
} else {
setOpen(false);
goBackToPreviousHotkeysScope();
goBackToPreviousHotkeyScope();
}
}