mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Revert change as it had some issue with hooks
This commit is contained in:
parent
09dd9a62e3
commit
7eeed4db81
1 changed files with 12 additions and 18 deletions
|
|
@ -43,27 +43,21 @@ const keysReducer = (
|
|||
}
|
||||
}
|
||||
|
||||
// Labels
|
||||
const useInitialKeyMapping = (commands: KeyboardCommand[]): KeyPressed => {
|
||||
const currentKeys: KeyPressed = {}
|
||||
commands.forEach((command) => {
|
||||
command.shortcutKeys.forEach((key) => {
|
||||
const aliases = key.split('|')
|
||||
aliases.forEach((k) => {
|
||||
currentKeys[k.toLowerCase()] = false
|
||||
export const useKeyboardShortcuts = (commands: KeyboardCommand[]): void => {
|
||||
const initalKeyMapping = useMemo(() => {
|
||||
const currentKeys: KeyPressed = {}
|
||||
commands.forEach((command) => {
|
||||
command.shortcutKeys.forEach((key) => {
|
||||
const aliases = key.split('|')
|
||||
aliases.forEach((k) => {
|
||||
currentKeys[k.toLowerCase()] = false
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
KBAR_KEYS.map((key) => (currentKeys[key.toLowerCase()] = false))
|
||||
return currentKeys
|
||||
}
|
||||
|
||||
export const useKeyboardShortcuts = (commands: KeyboardCommand[]): void => {
|
||||
const initalKeyMapping = useMemo(
|
||||
() => useInitialKeyMapping(commands),
|
||||
[commands]
|
||||
)
|
||||
KBAR_KEYS.map((key) => (currentKeys[key.toLowerCase()] = false))
|
||||
return currentKeys
|
||||
}, [commands])
|
||||
|
||||
const [keys, setKeys] = useReducer(keysReducer, initalKeyMapping)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue