fix: make sure new nodes are reactive

Closes #7
This commit is contained in:
2025-12-02 16:59:11 +01:00
parent d178f812fb
commit 2b4c81f557

View File

@@ -178,7 +178,6 @@ export class GraphManager extends EventEmitter<{
const nodeType = this.registry.getNode(node.type);
if (nodeType) {
node.tmp = {
random: (Math.random() - 0.5) * 2,
type: nodeType,
};
}
@@ -234,7 +233,6 @@ export class GraphManager extends EventEmitter<{
return;
}
node.tmp = node.tmp || {};
node.tmp.random = (Math.random() - 0.5) * 2;
node.tmp.type = nodeType;
}
@@ -460,13 +458,13 @@ export class GraphManager extends EventEmitter<{
return;
}
const node: Node = {
const node: Node = $state({
id: this.createNodeId(),
type,
position,
tmp: { type: nodeType },
props,
};
});
this.nodes.set(node.id, node);