diff options
| author | Anwarul Islam <anwaarulislaam@gmail.com> | 2025-07-18 08:30:42 +0600 |
|---|---|---|
| committer | Anwarul Islam <anwaarulislaam@gmail.com> | 2025-07-18 08:30:42 +0600 |
| commit | c3caefc001e1ea6a7e5626acb1fe1054fa00a56a (patch) | |
| tree | 1780e09a517612acc9a53ca94ddb7577705947a4 /apps/web/src/constants | |
| parent | 8e4661951d214f917357caef9d2895f2a4f7eb1e (diff) | |
| download | opencut-c3caefc001e1ea6a7e5626acb1fe1054fa00a56a.tar.gz | |
feat: enhance keybinding import validation and improve error handling
Diffstat (limited to 'apps/web/src/constants')
| -rw-r--r-- | apps/web/src/constants/actions.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/apps/web/src/constants/actions.ts b/apps/web/src/constants/actions.ts index 95a1e645..5f1883f1 100644 --- a/apps/web/src/constants/actions.ts +++ b/apps/web/src/constants/actions.ts @@ -233,19 +233,19 @@ export function useActionHandler<A extends Action>( // Handle ref-based isActive changes useEffect(() => { if (isActive && typeof isActive === "object" && "current" in isActive) { - const checkActive = () => { + // Poll for ref changes + const interval = setInterval(() => { const shouldBind = isActive.current; - if (shouldBind && !isBound) { - bindAction(action, stableHandler); - setIsBound(true); - } else if (!shouldBind && isBound) { - unbindAction(action, stableHandler); - setIsBound(false); + if (shouldBind !== isBound) { + if (shouldBind) { + bindAction(action, stableHandler); + } else { + unbindAction(action, stableHandler); + } + setIsBound(shouldBind); } - }; - - // Initial check - checkActive(); + }, 100); + return () => clearInterval(interval); } }, [action, stableHandler, isActive, isBound]); } |
