Unverified Commit d3a375c8 authored by ltdrdata's avatar ltdrdata Committed by GitHub
Browse files

Add support for file list refresh feature in node (#192)



* Added file reload feature to widgets.

* Modify feature name 'reload' to 'refresh' and fixed ignoring button name.

* refresh widget bugfix

* crash patch for "widget" input by type mismatch

* compensate offset on showimage
* adding widget caused misaligned offset

* patch refresh feature for general method

* clean up patch and following upstream

* make more clean code for refresh feature

* move refresh button position

* robust patch for refresh feature

* patch for refreh feature
* avoid specify REFRESH_LIST for each node
* prevent updating selected value unless removed item
* update all combo list for 'required input' in node

---------
Co-authored-by: default avatarLt.Dr.Data <lt.dr.data@gmail.com>
parent bb1223d8
...@@ -901,6 +901,31 @@ class ComfyApp { ...@@ -901,6 +901,31 @@ class ComfyApp {
} }
this.extensions.push(extension); this.extensions.push(extension);
} }
/**
* Refresh combo list on whole nodes
*/
async refreshComboInNodes() {
const defs = await api.getNodeDefs();
for(let nodeNum in this.graph._nodes) {
const node = this.graph._nodes[nodeNum];
const def = defs[node.type];
for(const widgetNum in node.widgets) {
const widget = node.widgets[widgetNum]
if(widget.type == "combo" && def["input"]["required"][widget.name] !== undefined) {
widget.options.values = def["input"]["required"][widget.name][0];
if(!widget.options.values.includes(widget.value)) {
widget.value = widget.options.values[0];
}
}
}
}
}
} }
export const app = new ComfyApp(); export const app = new ComfyApp();
...@@ -376,6 +376,7 @@ export class ComfyUI { ...@@ -376,6 +376,7 @@ export class ComfyUI {
}, },
}), }),
$el("button", { textContent: "Load", onclick: () => fileInput.click() }), $el("button", { textContent: "Load", onclick: () => fileInput.click() }),
$el("button", { textContent: "Refresh", onclick: () => app.refreshComboInNodes() }),
$el("button", { textContent: "Clear", onclick: () => app.graph.clear() }), $el("button", { textContent: "Clear", onclick: () => app.graph.clear() }),
$el("button", { textContent: "Load Default", onclick: () => app.loadGraphData() }), $el("button", { textContent: "Load Default", onclick: () => app.loadGraphData() }),
]); ]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment