diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-26 13:52:30 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-29 15:49:30 +0200 |
| commit | 722dcdd88face3724c77d23bc36a00524e552551 (patch) | |
| tree | 9dbf561de29592d5a346b8c7bfd27b5d31345bc8 /apps/web/src/hooks | |
| parent | 8db3bead13441a5882d8689dfc6a9f09c82375d9 (diff) | |
| download | opencut-722dcdd88face3724c77d23bc36a00524e552551.tar.gz | |
fix: resolve typescript/lint errors
Diffstat (limited to 'apps/web/src/hooks')
| -rw-r--r-- | apps/web/src/hooks/use-keyboard-shortcuts-help.ts | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/apps/web/src/hooks/use-keyboard-shortcuts-help.ts b/apps/web/src/hooks/use-keyboard-shortcuts-help.ts index 80f7f07a..7ea3a555 100644 --- a/apps/web/src/hooks/use-keyboard-shortcuts-help.ts +++ b/apps/web/src/hooks/use-keyboard-shortcuts-help.ts @@ -2,7 +2,7 @@ import { useMemo } from "react"; import { useKeybindingsStore } from "@/stores/keybindings-store"; -import { ACTIONS, type TAction } from "@/lib/actions"; +import { ACTIONS, type TActionWithOptionalArgs } from "@/lib/actions"; import { getPlatformAlternateKey, getPlatformSpecialKey, @@ -13,7 +13,7 @@ export interface KeyboardShortcut { keys: string[]; description: string; category: string; - action: TAction; + action: TActionWithOptionalArgs; icon?: React.ReactNode; } @@ -40,9 +40,11 @@ export function useKeyboardShortcutsHelp() { const shortcuts = useMemo(() => { const result: KeyboardShortcut[] = []; - const actionToKeys: Record<string, string[]> = {}; + const actionToKeys: Partial<Record<TActionWithOptionalArgs, string[]>> = {}; - for (const [key, action] of Object.entries(keybindings)) { + for (const [key, action] of Object.entries(keybindings) as Array< + [string, TActionWithOptionalArgs | undefined] + >) { if (action) { if (!actionToKeys[action]) { actionToKeys[action] = []; @@ -51,16 +53,16 @@ export function useKeyboardShortcutsHelp() { } } - for (const [actionId, keys] of Object.entries(actionToKeys)) { - if (!isAction(actionId)) continue; - - const actionDef = ACTIONS[actionId]; + for (const [action, keys] of Object.entries(actionToKeys) as Array< + [TActionWithOptionalArgs, string[]] + >) { + const actionDef = ACTIONS[action]; result.push({ - id: actionId, + id: action, keys, description: actionDef.description, category: actionDef.category, - action: actionId, + action, }); } @@ -76,7 +78,3 @@ export function useKeyboardShortcutsHelp() { shortcuts, }; } - -function isAction(id: string): id is TAction { - return id in ACTIONS; -} |
