Re-enable keybinding jest test (#2090)

This commit is contained in:
Chenlei Hu
2024-12-29 14:55:18 -05:00
committed by GitHub
parent 773059da93
commit 95a4623c37
6 changed files with 65 additions and 68 deletions

View File

@@ -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
}