auto clean up output slot for sam node

This commit is contained in:
BennyKok
2023-09-27 13:19:47 +08:00
parent 5ed89b7440
commit 584da94d04
+18
View File
@@ -4,6 +4,7 @@ import {
selectedLayer,
imagePromptsMulti,
targetNode,
showImageEditor,
} from "./state.js";
import { van } from "./van.js";
const {
@@ -22,6 +23,23 @@ const {
span,
} = van.tags;
van.derive(() => {
if (showImageEditor.val && targetNode.val != undefined && targetNode.val.outputs) {
const outputNames = targetNode.val.outputs.map(x => x.name).slice(1)
const record = Object.keys(imagePromptsMulti.val)
const diff = outputNames.filter(x => !record.includes(x));
if (diff.length === 0) return;
console.log("Cleaning up missing output slots", diff);
diff.forEach((x) => {
targetNode.val.removeOutput(targetNode.val.findOutputSlot(x))
})
targetNode.val.graph.change();
}
})
export function SideBar() {
const layer_to_delete = van.state("");