Better serialize widget values

This commit is contained in:
space-nuko
2023-05-03 22:53:05 -05:00
parent 3d55badda8
commit e9326e50b5
5 changed files with 36 additions and 15 deletions

View File

@@ -12,7 +12,7 @@
$: widget && setNodeValue(widget);
$: if ($propsChanged && nodeValue !== null) {
$: if (nodeValue !== null && (!$propsChanged || $propsChanged)) {
setOption($nodeValue)
setNodeValue(widget)
node.properties = node.properties

View File

@@ -20,7 +20,9 @@
}
};
$: if ($propsChanged && nodeValue !== null) {
// I don't know why but this is necessary to watch for changes to node
// properties from ComfyWidgetNode.
$: if (nodeValue !== null && (!$propsChanged || $propsChanged)) {
setOption($nodeValue)
setNodeValue(widget)
node.properties = node.properties

View File

@@ -6,12 +6,25 @@
export let widget: WidgetLayout | null = null;
let node: ComfyComboNode | null = null;
let nodeValue: Writable<string> | null = null;
let propsChanged: Writable<boolean> | null = null;
let itemValue: WidgetUIStateStore | null = null;
$: if(widget) {
node = widget.node as ComfyComboNode
nodeValue = node.value;
$: widget && setNodeValue(widget);
function setNodeValue(widget: WidgetLayout) {
if (widget) {
node = widget.node as ComfySliderNode
nodeValue = node.value;
propsChanged = node.propsChanged;
}
};
// I don't know why but this is necessary to watch for changes to node
// properties from ComfyWidgetNode.
$: if (nodeValue !== null && (!$propsChanged || $propsChanged)) {
setNodeValue(widget)
node.properties = node.properties
}
</script>
<div class="wrapper gr-textbox">