mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 07:44:11 +00:00
Prune widgets on graph configure (#3716)
This commit is contained in:
@@ -314,3 +314,18 @@ LGraphNode.prototype.addDOMWidget = function <
|
||||
|
||||
return widget
|
||||
}
|
||||
|
||||
/**
|
||||
* Prunes widgets that are no longer in the graph.
|
||||
* @param nodes The nodes to prune widgets for.
|
||||
*/
|
||||
export const pruneWidgets = (nodes: LGraphNode[]) => {
|
||||
const nodeSet = new Set(nodes)
|
||||
const domWidgetStore = useDomWidgetStore()
|
||||
for (const widgetState of domWidgetStore.widgetStates.values()) {
|
||||
const widget = widgetState.widget
|
||||
if (!nodeSet.has(widget.node as LGraphNode)) {
|
||||
domWidgetStore.unregisterWidget(widget.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user