From 407f9b899e3ddf0c00da7053b852a09e473f8f29 Mon Sep 17 00:00:00 2001 From: Ping <5123601+pingren@users.noreply.github.com> Date: Fri, 17 Nov 2023 20:47:46 +0800 Subject: [PATCH] feat: delay share condition check --- js/comfyui-manager.js | 25 ++----------------------- js/comfyui-share-common.js | 29 +++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/js/comfyui-manager.js b/js/comfyui-manager.js index 492fd403..aae8b853 100644 --- a/js/comfyui-manager.js +++ b/js/comfyui-manager.js @@ -590,30 +590,9 @@ app.registerExtension({ if(!ShareDialogChooser.instance) { ShareDialogChooser.instance = new ShareDialogChooser(); } - // TODO: DEV ONLY, remove this line - ShareDialogChooser.instance.show({ potential_outputs : [], potential_output_nodes: [] }); + + ShareDialogChooser.instance.show(); return - - app.graphToPrompt().then(prompt => { - // console.log({ prompt }) - return app.graph._nodes; - }).then(nodes => { - // console.log({ nodes }); - const { potential_outputs, potential_output_nodes } = getPotentialOutputsAndOutputNodes(nodes); - - if (potential_outputs.length === 0) { - if (potential_output_nodes.length === 0) { - // todo: add support for other output node types (animatediff combine, etc.) - const supported_nodes_string = SUPPORTED_OUTPUT_NODE_TYPES.join(", "); - alert(`No supported output node found (${supported_nodes_string}). To share this workflow, please add an output node to your graph and re-run your prompt.`); - } else { - alert("To share this, first run a prompt. Once it's done, click 'Share'.\n\nNOTE: Images of the Share target can only be selected in the PreviewImage, SaveImage, and VHS_VideoCombine nodes. In the case of VHS_VideoCombine, only the image/gif and image/webp formats are supported."); - } - return; - } - - ShareDialogChooser.instance.show({ potential_outputs, potential_output_nodes }); - }); } // make the background color a gradient of blue to green shareButton.style.background = "linear-gradient(90deg, #00C9FF 0%, #92FE9D 100%)"; diff --git a/js/comfyui-share-common.js b/js/comfyui-share-common.js index 48bf794a..6f99d74d 100644 --- a/js/comfyui-share-common.js +++ b/js/comfyui-share-common.js @@ -170,7 +170,7 @@ export class ShareDialogChooser extends ComfyDialog { if (!OpenArtShareDialog.instance) { OpenArtShareDialog.instance = new OpenArtShareDialog(); } - OpenArtShareDialog.instance.show({ potential_outputs: this.potential_output_nodes, potential_output_nodes: this.potential_output_nodes }) + OpenArtShareDialog.instance.show() this.close(); } @@ -178,8 +178,27 @@ export class ShareDialogChooser extends ComfyDialog { if (!ShareDialog.instance) { ShareDialog.instance = new ShareDialog(); } - ShareDialog.instance.show({ potential_outputs: this.potential_output_nodes, potential_output_nodes: this.potential_output_nodes }) - this.close(); + app.graphToPrompt().then(prompt => { + // console.log({ prompt }) + return app.graph._nodes; + }).then(nodes => { + // console.log({ nodes }); + const { potential_outputs, potential_output_nodes } = getPotentialOutputsAndOutputNodes(nodes); + + if (potential_outputs.length === 0) { + if (potential_output_nodes.length === 0) { + // todo: add support for other output node types (animatediff combine, etc.) + const supported_nodes_string = SUPPORTED_OUTPUT_NODE_TYPES.join(", "); + alert(`No supported output node found (${supported_nodes_string}). To share this workflow, please add an output node to your graph and re-run your prompt.`); + } else { + alert("To share this, first run a prompt. Once it's done, click 'Share'.\n\nNOTE: Images of the Share target can only be selected in the PreviewImage, SaveImage, and VHS_VideoCombine nodes. In the case of VHS_VideoCombine, only the image/gif and image/webp formats are supported."); + } + return; + } + + ShareDialogChooser.instance.show({ potential_outputs, potential_output_nodes }); + this.close(); + }); } const buttons = [ @@ -336,10 +355,8 @@ export class ShareDialogChooser extends ComfyDialog { ]), ]; } - show({ potential_outputs, potential_output_nodes }) { + show() { this.element.style.display = "block"; - this.potential_outputs = potential_outputs; - this.potential_output_nodes = potential_output_nodes; } } export class ShareDialog extends ComfyDialog {