From 7befc2c43e7e06d6354dd46f7a9a08e5b132f829 Mon Sep 17 00:00:00 2001 From: Palazzini Luca Date: Wed, 11 Sep 2024 12:59:06 +0200 Subject: [PATCH] Improve static inputs --- web/visual_area_prompt.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/web/visual_area_prompt.js b/web/visual_area_prompt.js index de0bfde..0066422 100644 --- a/web/visual_area_prompt.js +++ b/web/visual_area_prompt.js @@ -68,21 +68,25 @@ app.registerExtension({ } console.log(slot_idx, link_info, node_slot); // Track each slot name so we can index the uniques - let idx = indexesToSkip.length == 0 ? 0 : Math.max(...indexesToSkip) + 1; // Skip the static ones + let idx = 0; let slot_tracker = {}; - const actualInputs = this.inputs.slice(idx); - for (const slot of actualInputs) { - if (slot.link === null) { - this.removeInput(idx); - continue; + for (const slot of this.inputs) { + // Skip the static ones + if (indexesToSkip.includes(idx)) { + idx += 1; + } else { + if (slot.link === null) { + this.removeInput(idx); + continue; + } + idx += 1; + const name = slot.name.split('_')[0]; + // Correctly increment the count in slot_tracker + const count = (slot_tracker[name] || 0) + 1; + slot_tracker[name] = count; + // Update the slot name with the count if greater than 1 + slot.name = `${name}_${count}`; } - idx += 1; - const name = slot.name.split('_')[0]; - // Correctly increment the count in slot_tracker - const count = (slot_tracker[name] || 0) + 1; - slot_tracker[name] = count; - // Update the slot name with the count if greater than 1 - slot.name = `${name}_${count}`; } // Add last input to fix the removed ones const last = this.inputs[this.inputs.length - 1];