fix(keybindings): serialize KeybindingImpl to plain object before persisting

_.isEqual compares constructors, so KeybindingImpl instances are never
equal to the plain objects returned by the backend. Serialize bindings
to plain objects before passing to setMany so the deep-equality check
in settingStore can correctly skip redundant writes.
This commit is contained in:
Kelly Yang
2026-05-05 14:24:27 -07:00
parent 55a558f323
commit 63fff48ce6

View File

@@ -124,13 +124,25 @@ export function useKeybindingService() {
}
async function persistUserKeybindings() {
const toPlain = (b: KeybindingImpl) => ({
commandId: b.commandId,
combo: {
key: b.combo.key,
ctrl: b.combo.ctrl,
alt: b.combo.alt,
shift: b.combo.shift
},
...(b.targetElementId !== undefined && {
targetElementId: b.targetElementId
})
})
await settingStore.setMany({
'Comfy.Keybinding.NewBindings': Object.values(
keybindingStore.getUserKeybindings()
),
).map(toPlain),
'Comfy.Keybinding.UnsetBindings': Object.values(
keybindingStore.getUserUnsetKeybindings()
)
).map(toPlain)
})
}