Only show the Paste menu if the ComfyApp.clipspace is not empty

This commit is contained in:
Lt.Dr.Data 2023-04-21 15:45:22 +09:00
parent a364df24cc
commit 5920edba3a

View File

@ -160,51 +160,55 @@ export class ComfyApp {
'images': this.images 'images': this.images
}; };
} }
}, });
{
content: "Paste (Clipspace)", if(ComfyApp.clipspace != null) {
callback: () => { options.push(
if(ComfyApp.clipspace != null) { {
if(ComfyApp.clipspace.widgets != null && this.widgets != null) { content: "Paste (Clipspace)",
ComfyApp.clipspace.widgets.forEach(({ type, name, value }) => { callback: () => {
const prop = Object.values(this.widgets).find(obj => obj.type === type && obj.name === name); if(ComfyApp.clipspace != null) {
if (prop) { if(ComfyApp.clipspace.widgets != null && this.widgets != null) {
prop.value = value; ComfyApp.clipspace.widgets.forEach(({ type, name, value }) => {
const prop = Object.values(this.widgets).find(obj => obj.type === type && obj.name === name);
if (prop) {
prop.value = value;
}
});
}
// image paste
if(ComfyApp.clipspace.imgs != undefined && this.imgs != undefined && this.widgets != null) {
var filename = "";
if(this.images && ComfyApp.clipspace.images) {
this.images = ComfyApp.clipspace.images;
} }
});
}
// image paste if(ComfyApp.clipspace.images != undefined) {
if(ComfyApp.clipspace.imgs != undefined && this.imgs != undefined && this.widgets != null) { filename = `${ComfyApp.clipspace.images[0].filename} [${ComfyApp.clipspace.images[0].type}]`;
var filename = ""; }
if(this.images && ComfyApp.clipspace.images) { else if(ComfyApp.clipspace.widgets != undefined) {
this.images = ComfyApp.clipspace.images; const index_in_clip = ComfyApp.clipspace.widgets.findIndex(obj => obj.name === 'image');
} if(index_in_clip >= 0) {
filename = `${ComfyApp.clipspace.widgets[index_in_clip].value}`;
if(ComfyApp.clipspace.images != undefined) { }
filename = `${ComfyApp.clipspace.images[0].filename} [${ComfyApp.clipspace.images[0].type}]`;
}
else if(ComfyApp.clipspace.widgets != undefined) {
const index_in_clip = ComfyApp.clipspace.widgets.findIndex(obj => obj.name === 'image');
if(index_in_clip >= 0) {
filename = `${ComfyApp.clipspace.widgets[index_in_clip].value}`;
} }
}
const index = this.widgets.findIndex(obj => obj.name === 'image'); const index = this.widgets.findIndex(obj => obj.name === 'image');
if(index >= 0 && filename != "" && ComfyApp.clipspace.imgs != undefined) { if(index >= 0 && filename != "" && ComfyApp.clipspace.imgs != undefined) {
this.imgs = ComfyApp.clipspace.imgs; this.imgs = ComfyApp.clipspace.imgs;
this.widgets[index].value = filename; this.widgets[index].value = filename;
if(this.widgets_values != undefined) { if(this.widgets_values != undefined) {
this.widgets_values[index] = filename; this.widgets_values[index] = filename;
}
} }
} }
} }
} }
} }
} );
); }
}; };
} }