mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-23 07:50:15 +00:00
Re-enable keybinding jest test (#2090)
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, Ref, ref, toRaw } from 'vue'
|
||||
import { Keybinding, KeyCombo } from '@/types/keyBindingTypes'
|
||||
import { useSettingStore } from './settingStore'
|
||||
import { CORE_KEYBINDINGS } from '@/constants/coreKeybindings'
|
||||
import type { ComfyExtension } from '@/types/comfy'
|
||||
|
||||
export class KeybindingImpl implements Keybinding {
|
||||
commandId: string
|
||||
@@ -245,54 +242,6 @@ export const useKeybindingStore = defineStore('keybinding', () => {
|
||||
return true
|
||||
}
|
||||
|
||||
function loadUserKeybindings() {
|
||||
const settingStore = useSettingStore()
|
||||
// Unset bindings first as new bindings might conflict with default bindings.
|
||||
const unsetBindings = settingStore.get('Comfy.Keybinding.UnsetBindings')
|
||||
for (const keybinding of unsetBindings) {
|
||||
unsetKeybinding(new KeybindingImpl(keybinding))
|
||||
}
|
||||
const newBindings = settingStore.get('Comfy.Keybinding.NewBindings')
|
||||
for (const keybinding of newBindings) {
|
||||
addUserKeybinding(new KeybindingImpl(keybinding))
|
||||
}
|
||||
}
|
||||
|
||||
function loadCoreKeybindings() {
|
||||
for (const keybinding of CORE_KEYBINDINGS) {
|
||||
addDefaultKeybinding(new KeybindingImpl(keybinding))
|
||||
}
|
||||
}
|
||||
|
||||
function loadExtensionKeybindings(extension: ComfyExtension) {
|
||||
if (extension.keybindings) {
|
||||
for (const keybinding of extension.keybindings) {
|
||||
try {
|
||||
addDefaultKeybinding(new KeybindingImpl(keybinding))
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
`Failed to load keybinding for extension ${extension.name}`,
|
||||
error
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function persistUserKeybindings() {
|
||||
const settingStore = useSettingStore()
|
||||
// TODO(https://github.com/Comfy-Org/ComfyUI_frontend/issues/1079):
|
||||
// Allow setting multiple values at once in settingStore
|
||||
await settingStore.set(
|
||||
'Comfy.Keybinding.NewBindings',
|
||||
Object.values(userKeybindings.value)
|
||||
)
|
||||
await settingStore.set(
|
||||
'Comfy.Keybinding.UnsetBindings',
|
||||
Object.values(userUnsetKeybindings.value)
|
||||
)
|
||||
}
|
||||
|
||||
function resetKeybindings() {
|
||||
userKeybindings.value = {}
|
||||
userUnsetKeybindings.value = {}
|
||||
@@ -312,6 +261,8 @@ export const useKeybindingStore = defineStore('keybinding', () => {
|
||||
|
||||
return {
|
||||
keybindings,
|
||||
userKeybindings,
|
||||
userUnsetKeybindings,
|
||||
getKeybinding,
|
||||
getKeybindingsByCommandId,
|
||||
getKeybindingByCommandId,
|
||||
@@ -319,10 +270,6 @@ export const useKeybindingStore = defineStore('keybinding', () => {
|
||||
addUserKeybinding,
|
||||
unsetKeybinding,
|
||||
updateKeybindingOnCommand,
|
||||
loadUserKeybindings,
|
||||
loadCoreKeybindings,
|
||||
loadExtensionKeybindings,
|
||||
persistUserKeybindings,
|
||||
resetKeybindings,
|
||||
isCommandKeybindingModified
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user