From 55cd0db336d34d85dae04efec5003414da21dbfb Mon Sep 17 00:00:00 2001 From: tritant Date: Tue, 23 Sep 2025 18:48:08 +0200 Subject: [PATCH] fix refresh --- js/orchestratortoogle.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/js/orchestratortoogle.js b/js/orchestratortoogle.js index eb8c23d..201a615 100644 --- a/js/orchestratortoogle.js +++ b/js/orchestratortoogle.js @@ -1,5 +1,6 @@ import { app } from "/scripts/app.js"; +// La fonction updateNodeStates reste la même function updateNodeStates(selectedWorkflow, workflowTags) { const changesToApply = []; for (const targetNode of app.graph.nodes) { @@ -13,11 +14,7 @@ function updateNodeStates(selectedWorkflow, workflowTags) { } } if (isTaggedNode) { - // --- LOGIQUE MODIFIÉE --- - // Si un workflow est sélectionné ET que c'est le bon, on active. - // Sinon (si aucun n'est sélectionné ou si c'est le mauvais tag), on bypasse. const newMode = (selectedWorkflow && title.startsWith(`[[${selectedWorkflow}]]`)) ? 0 : 4; - if (targetNode.mode !== newMode) { changesToApply.push({ node: targetNode, mode: newMode }); } @@ -32,19 +29,17 @@ function updateNodeStates(selectedWorkflow, workflowTags) { } app.registerExtension({ - name: "Comfy.OrchestratorNodeMuter.AutoDiscovery", + name: "Comfy.OrchestratorNodeMuter.AutoDiscovery.Final", + + // La fonction 'setup' a été entièrement supprimée. beforeRegisterNodeDef(nodeType, nodeData, app) { if (nodeData.name === "OrchestratorNodeMuter") { const onNodeCreated = nodeType.prototype.onNodeCreated; nodeType.prototype.onNodeCreated = function () { onNodeCreated?.apply(this, arguments); - - if (!this.widgets) { - this.widgets = []; - } - const discoverAndBuildUI = () => { + this.discoverAndBuildUI = () => { if(this.widgets?.length > 0) { this.widgets.length = 0; } @@ -67,14 +62,11 @@ app.registerExtension({ const WORKFLOW_TAGS = Array.from(discoveredTags); if (WORKFLOW_TAGS.length === 0) return; - this.widgets.push({ name: "top_spacer", type: "CUSTOM_SPACER", draw: () => {}, computeSize: () => [0, 25] }); + this.widgets.push({ name: "top_spacer", type: "CUSTOM_SPACER", draw: () => {}, computeSize: () => [0, 10] }); - // --- LOGIQUE MODIFIÉE --- const handleToggleClick = (toggledWidgetName, isTurningOn) => { let newSelectedWorkflow = null; - if (isTurningOn) { - // Si on active un interrupteur, on désactive les autres. newSelectedWorkflow = toggledWidgetName; for (const w of this.widgets) { if (WORKFLOW_TAGS.includes(w.name) && w.name !== toggledWidgetName) { @@ -82,8 +74,6 @@ app.registerExtension({ } } } - // Si on désactive un interrupteur (isTurningOn = false), newSelectedWorkflow reste null. - setTimeout(() => { updateNodeStates(newSelectedWorkflow, WORKFLOW_TAGS); }, 0); }; @@ -94,11 +84,14 @@ app.registerExtension({ const firstWidget = this.widgets.find(w => w.name === WORKFLOW_TAGS[0]); if (firstWidget) { firstWidget.value = true; - setTimeout(() => { updateNodeStates(firstWidget.name, WORKFLOW_TAGS); }, 200); + setTimeout(() => { updateNodeStates(firstWidget.name, WORKFLOW_TAGS); }, 0); } }; - discoverAndBuildUI(); + // On retarde le premier scan pour laisser le temps au graphe de se charger. + setTimeout(() => { + this.discoverAndBuildUI(); + }, 100); // Un délai de 100ms est généralement suffisant. }; } },