Fix saved keybinding persistence (#2176)

This commit is contained in:
bymyself
2025-01-06 13:54:35 -07:00
committed by huchenlei
parent 3195e8a697
commit ca33015ced
3 changed files with 67 additions and 4 deletions

View File

@@ -84,11 +84,11 @@ export const useKeybindingService = () => {
// Allow setting multiple values at once in settingStore
await settingStore.set(
'Comfy.Keybinding.NewBindings',
Object.values(keybindingStore.userKeybindings.value)
Object.values(keybindingStore.getUserKeybindings())
)
await settingStore.set(
'Comfy.Keybinding.UnsetBindings',
Object.values(keybindingStore.userUnsetKeybindings.value)
Object.values(keybindingStore.getUserUnsetKeybindings())
)
}

View File

@@ -105,6 +105,20 @@ export const useKeybindingStore = defineStore('keybinding', () => {
*/
const userUnsetKeybindings = ref<Record<string, KeybindingImpl>>({})
/**
* Get user-defined keybindings.
*/
function getUserKeybindings() {
return userKeybindings.value
}
/**
* Get user-defined keybindings that unset default keybindings.
*/
function getUserUnsetKeybindings() {
return userUnsetKeybindings.value
}
const keybindingByKeyCombo = computed<Record<string, KeybindingImpl>>(() => {
const result: Record<string, KeybindingImpl> = {
...defaultKeybindings.value
@@ -262,8 +276,8 @@ export const useKeybindingStore = defineStore('keybinding', () => {
return {
keybindings,
userKeybindings,
userUnsetKeybindings,
getUserKeybindings,
getUserUnsetKeybindings,
getKeybinding,
getKeybindingsByCommandId,
getKeybindingByCommandId,