fix refresh
This commit is contained in:
+11
-18
@@ -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.
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user