summaryrefslogtreecommitdiff
path: root/apps/web/src/hooks/use-keybinding-conflicts.ts
diff options
context:
space:
mode:
authorMaze <167211895+mazeincoding@users.noreply.github.com>2026-01-31 00:20:04 +0100
committerGitHub <noreply@github.com>2026-01-31 00:20:04 +0100
commit7bf0984698e43b9aa2dd879f65951318ed410390 (patch)
treeccf2cd590a47d550152afc07129cb55c71a9ec35 /apps/web/src/hooks/use-keybinding-conflicts.ts
parent0173db99448d1c4c6415dcf15272e17551b48b04 (diff)
downloadopencut-7bf0984698e43b9aa2dd879f65951318ed410390.tar.gz
codebase overhaul (#697)
Diffstat (limited to 'apps/web/src/hooks/use-keybinding-conflicts.ts')
-rw-r--r--apps/web/src/hooks/use-keybinding-conflicts.ts59
1 files changed, 0 insertions, 59 deletions
diff --git a/apps/web/src/hooks/use-keybinding-conflicts.ts b/apps/web/src/hooks/use-keybinding-conflicts.ts
deleted file mode 100644
index cc5dd340..00000000
--- a/apps/web/src/hooks/use-keybinding-conflicts.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-"use client";
-
-import { useMemo } from "react";
-import { useKeybindingsStore } from "@/stores/keybindings-store";
-import { ActionWithOptionalArgs } from "@/constants/actions";
-
-export interface KeybindingConflictInfo {
- key: string;
- actions: ActionWithOptionalArgs[];
- isConflict: boolean;
-}
-
-export const useKeybindingConflicts = () => {
- const { keybindings } = useKeybindingsStore();
-
- const conflicts = useMemo(() => {
- const keyToActions: Record<string, ActionWithOptionalArgs[]> = {};
- const conflictList: KeybindingConflictInfo[] = [];
-
- // Group actions by key
- Object.entries(keybindings).forEach(([key, action]) => {
- if (!keyToActions[key]) {
- keyToActions[key] = [];
- }
- keyToActions[key].push(action);
- });
-
- // Find conflicts
- Object.entries(keyToActions).forEach(([key, actions]) => {
- const uniqueActions = [...new Set(actions)];
- conflictList.push({
- key,
- actions: uniqueActions,
- isConflict: uniqueActions.length > 1,
- });
- });
-
- return conflictList.filter((item) => item.isConflict);
- }, [keybindings]);
-
- const hasConflicts = conflicts.length > 0;
-
- const getConflictsForKey = (key: string): KeybindingConflictInfo | null => {
- return conflicts.find((conflict) => conflict.key === key) || null;
- };
-
- const getConflictsForAction = (
- action: ActionWithOptionalArgs
- ): KeybindingConflictInfo[] => {
- return conflicts.filter((conflict) => conflict.actions.includes(action));
- };
-
- return {
- conflicts,
- hasConflicts,
- getConflictsForKey,
- getConflictsForAction,
- };
-};