mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
refactor: remove react-hotkeys-hook and use inertia propos instead of recreating a local store
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import KEYS from '#core/constants/keys';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { useHotkeys } from '@mantine/hooks';
|
||||
import { useGlobalHotkeysStore } from '~/stores/global_hotkeys_store';
|
||||
|
||||
type ShortcutOptions = {
|
||||
@@ -16,15 +16,12 @@ export default function useShortcut(
|
||||
}
|
||||
) {
|
||||
const { globalHotkeysEnabled } = useGlobalHotkeysStore();
|
||||
const isEnabled = disableGlobalCheck
|
||||
? enabled
|
||||
: enabled && globalHotkeysEnabled;
|
||||
return useHotkeys(
|
||||
KEYS[key],
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
cb();
|
||||
},
|
||||
{
|
||||
enabled: disableGlobalCheck ? enabled : enabled && globalHotkeysEnabled,
|
||||
enableOnFormTags: ['INPUT'],
|
||||
}
|
||||
[[KEYS[key], () => isEnabled && cb(), { preventDefault: true }]],
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user