Use updated updateSlotVisibility and debounce

This commit is contained in:
relhamdi
2026-05-28 10:32:34 +02:00
parent accad0c689
commit 30fed09bb3
2 changed files with 19 additions and 6 deletions
+12 -3
View File
@@ -1,4 +1,9 @@
import { createEditor, escapeHtml, updateSlotVisibility } from "./utils.js";
import {
createEditor,
debounce,
escapeHtml,
updateSlotVisibility,
} from "./utils.js";
import { app } from "/scripts/app.js";
// --- Constants ---
@@ -80,13 +85,17 @@ const attachEditor = (node) => {
editor.innerHTML = buildHighlightedHtml(textarea.value, connected);
};
const debouncedUpdate = debounce(() => {
updateSlotVisibility(node, NUM_SLOTS, "slot");
refreshDropdown(node, selectedWidget, comboWidget);
}, 64);
// --- Connection change hook - Re-render when slots are connected or disconnected ---
const originalConnectionChange = node.onConnectionsChange;
node.onConnectionsChange = function (...args) {
if (originalConnectionChange)
originalConnectionChange.call(this, ...args);
updateSlotVisibility(node, NUM_SLOTS, "slot");
renderColored();
debouncedUpdate();
};
// Initial render
+7 -3
View File
@@ -1,4 +1,4 @@
import { hideWidget, updateSlotVisibility } from "./utils.js";
import { debounce, hideWidget, updateSlotVisibility } from "./utils.js";
import { app } from "/scripts/app.js";
// --- Constants ---
@@ -71,13 +71,17 @@ const attachRouter = (node) => {
node.refreshDropdown = () =>
refreshDropdown(node, selectedWidget, comboWidget);
const debouncedUpdate = debounce(() => {
updateSlotVisibility(node, NUM_INPUTS, "input");
refreshDropdown(node, selectedWidget, comboWidget);
}, 64);
// --- Connection change hook - Re-render when nodes are connected or disconnected ---
const originalConnectionChange = node.onConnectionsChange;
node.onConnectionsChange = function (...args) {
if (originalConnectionChange)
originalConnectionChange.call(this, ...args);
updateSlotVisibility(node, NUM_INPUTS, "input");
node.refreshDropdown();
debouncedUpdate();
};
// Initial render