When dragging onto a node, don't let LiteGraph override title to default and check there's a workflow in the file before asking to replace workflow. Fixes #350

This commit is contained in:
rgthree
2024-10-11 21:41:45 -04:00
parent 206a6fac41
commit 6f82a5c72f
2 changed files with 13 additions and 8 deletions
@@ -47,17 +47,20 @@ export async function importIndividualNodesInnerOnDragDrop(node: ComfyNode, e: D
if (!handled && workflow) {
const exact = (workflow.nodes || []).find((n) => n.id === node.id && n.type === node.type);
if (
exact &&
exact.widgets_values?.length &&
exact?.widgets_values?.length &&
confirm(
"Found a node match from embedded workflow (same id & type) in this workflow. Would you like to set the widget values?",
)
) {
node.configure({ widgets_values: [...(exact?.widgets_values || [])] } as any);
node.configure({
// Title is overridden if it's not supplied; set it to the current then.
title: node.title,
widgets_values: [...(exact?.widgets_values || [])]
} as any);
handled = true;
}
}
if (!handled) {
if (!handled && workflow) {
handled = !confirm(
"No exact match found in workflow. Would you like to replace the whole workflow?",
);
@@ -38,14 +38,16 @@ export async function importIndividualNodesInnerOnDragDrop(node, e) {
const { workflow, prompt } = await tryToGetWorkflowDataFromEvent(e);
if (!handled && workflow) {
const exact = (workflow.nodes || []).find((n) => n.id === node.id && n.type === node.type);
if (exact &&
((_b = exact.widgets_values) === null || _b === void 0 ? void 0 : _b.length) &&
if (((_b = exact === null || exact === void 0 ? void 0 : exact.widgets_values) === null || _b === void 0 ? void 0 : _b.length) &&
confirm("Found a node match from embedded workflow (same id & type) in this workflow. Would you like to set the widget values?")) {
node.configure({ widgets_values: [...((exact === null || exact === void 0 ? void 0 : exact.widgets_values) || [])] });
node.configure({
title: node.title,
widgets_values: [...((exact === null || exact === void 0 ? void 0 : exact.widgets_values) || [])]
});
handled = true;
}
}
if (!handled) {
if (!handled && workflow) {
handled = !confirm("No exact match found in workflow. Would you like to replace the whole workflow?");
}
return handled;