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