Fix set workflow attribute in node
This commit is contained in:
@@ -32,9 +32,10 @@ export default class ComfyGraph extends LGraph {
|
||||
workflowID: WorkflowInstID | null = null;
|
||||
|
||||
get workflow(): ComfyWorkflow | null {
|
||||
if (this.workflowID == null)
|
||||
const workflowID = (this.getRootGraph() as ComfyGraph)?.workflowID;
|
||||
if (workflowID == null)
|
||||
return null;
|
||||
return workflowState.getWorkflow(this.workflowID)
|
||||
return workflowState.getWorkflow(workflowID)
|
||||
}
|
||||
|
||||
constructor(workflowID?: WorkflowInstID) {
|
||||
|
||||
@@ -30,9 +30,9 @@ export default class ComfyConfigureQueuePromptButton extends ComfyGraphNode {
|
||||
}
|
||||
|
||||
if (typeof param === "string")
|
||||
this.workflow.attrs.queuePromptButtonName = param || ""
|
||||
this.workflow.setAttribute("queuePromptButtonName", param || "")
|
||||
else if (typeof param === "object" && "buttonName" in param)
|
||||
this.workflow.attrs.queuePromptButtonName = param.buttonName || ""
|
||||
this.workflow.setAttribute("queuePromptButtonName", param.buttonName || "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,11 @@ export class ComfyWorkflow {
|
||||
store.set(get(store));
|
||||
}
|
||||
|
||||
setAttribute<K extends keyof WorkflowAttributes>(key: K, value: WorkflowAttributes[K]) {
|
||||
this.attrs[key] = value;
|
||||
this.notifyModified();
|
||||
}
|
||||
|
||||
start(key: string, canvas: ComfyGraphCanvas) {
|
||||
if (this.canvases[key] != null)
|
||||
throw new Error(`This workflow is already being displayed on canvas ${key}`)
|
||||
@@ -176,6 +181,7 @@ export class ComfyWorkflow {
|
||||
}
|
||||
|
||||
this.graph.configure(data.graph);
|
||||
this.graph.workflowID = this.id;
|
||||
|
||||
for (const node of this.graph._nodes) {
|
||||
const size = node.computeSize();
|
||||
@@ -228,9 +234,10 @@ function getWorkflow(id: WorkflowInstID): ComfyWorkflow | null {
|
||||
}
|
||||
|
||||
function getWorkflowByGraph(graph: LGraph): ComfyWorkflow | null {
|
||||
if ("workflowID" in graph && graph.workflowID != null)
|
||||
return getWorkflow((graph as ComfyGraph).workflowID);
|
||||
const workflowID = (graph.getRootGraph() as ComfyGraph)?.workflowID;
|
||||
if (workflowID == null)
|
||||
return null;
|
||||
return getWorkflow(workflowID);
|
||||
}
|
||||
|
||||
function getWorkflowByNode(node: LGraphNode): ComfyWorkflow | null {
|
||||
|
||||
Reference in New Issue
Block a user