diff options
| author | Kha Nguyen <hi@khanguyen.com> | 2025-07-22 18:52:49 -0500 |
|---|---|---|
| committer | Kha Nguyen <hi@khanguyen.com> | 2025-07-22 18:54:32 -0500 |
| commit | 901ddb509db23695cf9d71bf733e6a7185317960 (patch) | |
| tree | 5504e70278c5b2f4371cb6ddb3eccbed3ab1b054 /apps/web/src/stores | |
| parent | cabf86033032f0a396569cce9165cd656be791d6 (diff) | |
| download | opencut-901ddb509db23695cf9d71bf733e6a7185317960.tar.gz | |
fix: prevent action to perform on key press when edit keybindings
Diffstat (limited to 'apps/web/src/stores')
| -rw-r--r-- | apps/web/src/stores/keybindings-store.ts | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/apps/web/src/stores/keybindings-store.ts b/apps/web/src/stores/keybindings-store.ts index 3e525b86..ce2d839d 100644 --- a/apps/web/src/stores/keybindings-store.ts +++ b/apps/web/src/stores/keybindings-store.ts @@ -39,6 +39,7 @@ interface KeybindingsState { keybindings: KeybindingConfig; isCustomized: boolean; keybindingsEnabled: boolean; + isRecording: boolean; // Actions updateKeybinding: (key: ShortcutKey, action: ActionWithOptionalArgs) => void; @@ -48,11 +49,12 @@ interface KeybindingsState { exportKeybindings: () => KeybindingConfig; enableKeybindings: () => void; disableKeybindings: () => void; + setIsRecording: (isRecording: boolean) => void; // Validation validateKeybinding: ( key: ShortcutKey, - action: ActionWithOptionalArgs + action: ActionWithOptionalArgs, ) => KeybindingConflict | null; getKeybindingsForAction: (action: ActionWithOptionalArgs) => ShortcutKey[]; @@ -66,6 +68,7 @@ export const useKeybindingsStore = create<KeybindingsState>()( keybindings: { ...defaultKeybindings }, isCustomized: false, keybindingsEnabled: true, + isRecording: false, updateKeybinding: (key: ShortcutKey, action: ActionWithOptionalArgs) => { set((state) => { @@ -126,7 +129,7 @@ export const useKeybindingsStore = create<KeybindingsState>()( validateKeybinding: ( key: ShortcutKey, - action: ActionWithOptionalArgs + action: ActionWithOptionalArgs, ) => { const { keybindings } = get(); const existingAction = keybindings[key]; @@ -141,11 +144,14 @@ export const useKeybindingsStore = create<KeybindingsState>()( return null; }, + setIsRecording: (isRecording: boolean) => { + set({ isRecording }); + }, getKeybindingsForAction: (action: ActionWithOptionalArgs) => { const { keybindings } = get(); return Object.keys(keybindings).filter( - (key) => keybindings[key as ShortcutKey] === action + (key) => keybindings[key as ShortcutKey] === action, ) as ShortcutKey[]; }, @@ -156,8 +162,8 @@ export const useKeybindingsStore = create<KeybindingsState>()( { name: "opencut-keybindings", version: 1, - } - ) + }, + ), ); // Utility functions |
