Fix testing of valid links in pick first node
This commit is contained in:
@@ -101,25 +101,42 @@ export default class ComfyPickFirstNode extends ComfyGraphNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isValidLink(link: LLink | null): boolean {
|
||||||
|
if (!link)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const node = this.graph.getNodeById(link.origin_id);
|
||||||
|
|
||||||
|
// Links to deactivated nodes won't count.
|
||||||
|
if (!node || node.mode !== NodeMode.ALWAYS)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((node as ComfyGraphNode).isBackendNode) {
|
||||||
|
// Backend nodes won't set data, we can safely assume they're valid.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return link.data != null || this.properties.acceptNullLinkData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override getUpstreamLink(): LLink | null {
|
override getUpstreamLink(): LLink | null {
|
||||||
for (let index = 0; index < this.inputs.length; index++) {
|
for (let index = 0; index < this.inputs.length; index++) {
|
||||||
const link = this.getInputLink(index);
|
const link = this.getInputLink(index);
|
||||||
if (link != null && (link.data != null || this.properties.acceptNullLinkData)) {
|
if (this.isValidLink(link)) {
|
||||||
const node = this.getInputNode(index);
|
|
||||||
if (node != null && node.mode === NodeMode.ALWAYS) {
|
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
override onExecute() {
|
override onExecute() {
|
||||||
for (let index = 0; index < this.inputs.length; index++) {
|
for (let index = 0; index < this.inputs.length; index++) {
|
||||||
const link = this.getInputLink(index);
|
const link = this.getInputLink(index);
|
||||||
if (link != null && (link.data != null || this.properties.acceptNullLinkData)) {
|
if (this.isValidLink(link)) {
|
||||||
|
// Copy frontend-only inputs.
|
||||||
const node = this.getInputNode(index);
|
const node = this.getInputNode(index);
|
||||||
if (node != null && node.mode === NodeMode.ALWAYS) {
|
if (node != null && !(node as any).isBackendNode) {
|
||||||
this.selected = index;
|
this.selected = index;
|
||||||
this.displayWidget.value = Watch.toString(link.data)
|
this.displayWidget.value = Watch.toString(link.data)
|
||||||
this.setOutputData(0, link.data)
|
this.setOutputData(0, link.data)
|
||||||
|
|||||||
Reference in New Issue
Block a user