From 623afa2ced69085d7996921a0d312968a448109b Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Wed, 5 Apr 2023 10:51:04 +0100 Subject: [PATCH 1/4] Made accessing setting value easier Updated clear check to use this --- web/scripts/ui.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 91821fac..aea1a94b 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -115,14 +115,6 @@ function dragElement(dragEl, settings) { savePos = value; }, }); - - settings.addSetting({ - id: "Comfy.ConfirmClear", - name: "Require confirmation when clearing workflow", - type: "boolean", - defaultValue: true, - }); - function dragMouseDown(e) { e = e || window.event; e.preventDefault(); @@ -289,6 +281,16 @@ class ComfySettingsDialog extends ComfyDialog { return element; }, }); + + const self = this; + return { + get value() { + return self.getSettingValue(id); + }, + set value(v) { + self.setSettingValue(id, value); + }, + }; } show() { @@ -410,6 +412,13 @@ export class ComfyUI { this.history.update(); }); + const confirmClear = this.settings.addSetting({ + id: "Comfy.ConfirmClear", + name: "Require confirmation when clearing workflow", + type: "boolean", + defaultValue: true, + }); + const fileInput = $el("input", { type: "file", accept: ".json,image/png", @@ -517,13 +526,13 @@ export class ComfyUI { $el("button", { textContent: "Load", onclick: () => fileInput.click() }), $el("button", { textContent: "Refresh", onclick: () => app.refreshComboInNodes() }), $el("button", { textContent: "Clear", onclick: () => { - if (localStorage.getItem("Comfy.Settings.Comfy.ConfirmClear") == "false" || confirm("Clear workflow?")) { + if (!confirmClear.value || confirm("Clear workflow?")) { app.clean(); app.graph.clear(); } }}), $el("button", { textContent: "Load Default", onclick: () => { - if (localStorage.getItem("Comfy.Settings.Comfy.ConfirmClear") == "false" || confirm("Load default workflow?")) { + if (!confirmClear.value || confirm("Load default workflow?")) { app.loadGraphData() } }}), From db16932be5eec5446fbae898ca1365bfae58d90a Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Wed, 5 Apr 2023 10:52:35 +0100 Subject: [PATCH 2/4] Fix setting --- web/scripts/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/scripts/ui.js b/web/scripts/ui.js index aea1a94b..9952606d 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -288,7 +288,7 @@ class ComfySettingsDialog extends ComfyDialog { return self.getSettingValue(id); }, set value(v) { - self.setSettingValue(id, value); + self.setSettingValue(id, v); }, }; } From 1030ab0d8fd91e5c1167a087397047603102f069 Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Wed, 5 Apr 2023 11:02:34 +0100 Subject: [PATCH 3/4] Reload setting value --- web/scripts/ui.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 9952606d..b6b8e06b 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -225,6 +225,7 @@ class ComfySettingsDialog extends ComfyDialog { }; let element; + value = this.getSettingValue(id, defaultValue); if (typeof type === "function") { element = type(name, setter, value, attrs); @@ -418,7 +419,7 @@ export class ComfyUI { type: "boolean", defaultValue: true, }); - + const fileInput = $el("input", { type: "file", accept: ".json,image/png", From 5456b7555c6cc40a302ac9404603bfdf9c08f95c Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Wed, 5 Apr 2023 19:58:06 +0100 Subject: [PATCH 4/4] Add missing defaultValue arg --- web/scripts/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/scripts/ui.js b/web/scripts/ui.js index b6b8e06b..3af29ba7 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -286,7 +286,7 @@ class ComfySettingsDialog extends ComfyDialog { const self = this; return { get value() { - return self.getSettingValue(id); + return self.getSettingValue(id, defaultValue); }, set value(v) { self.setSettingValue(id, v);