Strip default value from gallery

This commit is contained in:
space-nuko
2023-05-25 17:12:20 -05:00
parent d70f430383
commit a47a032968
3 changed files with 13 additions and 118 deletions

View File

@@ -97,50 +97,7 @@
"title": "UI.Gallery", "title": "UI.Gallery",
"properties": { "properties": {
"tags": [], "tags": [],
"defaultValue": [ "defaultValue": [],
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06374_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": [],
"width": 512,
"height": 512
},
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06375_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": []
},
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06376_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": []
},
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06377_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": []
}
],
"index": 0, "index": 0,
"updateMode": "append", "updateMode": "append",
"autoSelectOnUpdate": true "autoSelectOnUpdate": true
@@ -148,50 +105,7 @@
"widgets_values": [], "widgets_values": [],
"color": "#223", "color": "#223",
"bgColor": "#335", "bgColor": "#335",
"comfyValue": [ "comfyValue": [],
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06374_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": [],
"width": 512,
"height": 512
},
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06375_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": []
},
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06376_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": []
},
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06377_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": []
}
],
"shownOutputProperties": {}, "shownOutputProperties": {},
"saveUserState": false "saveUserState": false
}, },
@@ -2586,20 +2500,7 @@
"title": "UI.Gallery", "title": "UI.Gallery",
"properties": { "properties": {
"tags": [], "tags": [],
"defaultValue": [ "defaultValue": [],
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06378_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": [],
"width": 0,
"height": 0
}
],
"index": 0, "index": 0,
"updateMode": "append", "updateMode": "append",
"autoSelectOnUpdate": true "autoSelectOnUpdate": true
@@ -2607,20 +2508,7 @@
"widgets_values": [], "widgets_values": [],
"color": "#223", "color": "#223",
"bgColor": "#335", "bgColor": "#335",
"comfyValue": [ "comfyValue": [],
{
"isComfyBoxImageMetadata": true,
"comfyUIFile": {
"filename": "ComfyUI_06378_.png",
"subfolder": "",
"type": "output"
},
"name": "File",
"tags": [],
"width": 0,
"height": 0
}
],
"shownOutputProperties": {}, "shownOutputProperties": {},
"saveUserState": false "saveUserState": false
}, },

View File

@@ -1,5 +1,5 @@
import { parseWhateverIntoImageMetadata, type ComfyBoxImageMetadata, type ComfyUploadImageType } from "$lib/utils"; import { parseWhateverIntoImageMetadata, type ComfyBoxImageMetadata, type ComfyUploadImageType } from "$lib/utils";
import { BuiltInSlotType, LiteGraph, type IComboWidget, type ITextWidget, type PropertyLayout, type SlotLayout, type INumberWidget, clamp } from "@litegraph-ts/core"; import { BuiltInSlotType, LiteGraph, type IComboWidget, type ITextWidget, type PropertyLayout, type SlotLayout, type INumberWidget, clamp, type SerializedLGraphNode } from "@litegraph-ts/core";
import { get, writable, type Writable } from "svelte/store"; import { get, writable, type Writable } from "svelte/store";
import GalleryWidget from "$lib/widgets/GalleryWidget.svelte"; import GalleryWidget from "$lib/widgets/GalleryWidget.svelte";
@@ -58,6 +58,7 @@ export default class ComfyGalleryNode extends ComfyWidgetNode<ComfyBoxImageMetad
this.selectedIndexWidget = this.addWidget("text", "Selected", String(get(this.selectedImage))) this.selectedIndexWidget = this.addWidget("text", "Selected", String(get(this.selectedImage)))
this.selectedIndexWidget.disabled = true; this.selectedIndexWidget.disabled = true;
this.modeWidget = this.addWidget("combo", "Mode", this.properties.updateMode, null, { property: "updateMode", values: ["replace", "append"] }) this.modeWidget = this.addWidget("combo", "Mode", this.properties.updateMode, null, { property: "updateMode", values: ["replace", "append"] })
this.defaultValue = []
} }
override onPropertyChanged(property: any, value: any) { override onPropertyChanged(property: any, value: any) {
@@ -103,6 +104,12 @@ export default class ComfyGalleryNode extends ComfyWidgetNode<ComfyBoxImageMetad
private _newSelectedIndex: number | null = null; private _newSelectedIndex: number | null = null;
override stripUserState(o: SerializedLGraphNode) {
super.stripUserState(o);
o.properties.defaultValue = [];
(o as any).comfyValue = [];
}
override parseValue(param: any): ComfyBoxImageMetadata[] { override parseValue(param: any): ComfyBoxImageMetadata[] {
if (param == null) if (param == null)
return [] return []

View File

@@ -355,6 +355,6 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
override stripUserState(o: SerializedLGraphNode) { override stripUserState(o: SerializedLGraphNode) {
super.stripUserState(o); super.stripUserState(o);
(o as any).comfyValue = this.properties.defaultValue; (o as any).comfyValue = LiteGraph.cloneObject(this.properties.defaultValue);
} }
} }