From ca8b1e15aca625d49a634701d2672e27726151fa Mon Sep 17 00:00:00 2001 From: Max Richter Date: Tue, 2 Dec 2025 16:59:43 +0100 Subject: [PATCH] chore: cleanup edge and node code --- app/src/lib/graph-interface/edges/Edge.svelte | 9 ++++----- app/src/lib/graph-interface/node/Node.svelte | 12 ++++-------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/app/src/lib/graph-interface/edges/Edge.svelte b/app/src/lib/graph-interface/edges/Edge.svelte index 598e67b..5c133b9 100644 --- a/app/src/lib/graph-interface/edges/Edge.svelte +++ b/app/src/lib/graph-interface/edges/Edge.svelte @@ -45,18 +45,17 @@ let mesh = $state(); - let lastId: number | null = null; - - const primeA = 31; - const primeB = 37; + let lastId: string | null = null; function update() { const new_x = to.x - from.x; const new_y = to.y - from.y; - const curveId = new_x * primeA + new_y * primeB; + const curveId = `${from.x}-${from.y}-${to.x}-${to.y}`; + if (lastId === curveId) { return; } + lastId = curveId; const length = Math.floor( Math.sqrt(Math.pow(new_x, 2) + Math.pow(new_y, 2)) / 4, diff --git a/app/src/lib/graph-interface/node/Node.svelte b/app/src/lib/graph-interface/node/Node.svelte index f52777f..58abb5e 100644 --- a/app/src/lib/graph-interface/node/Node.svelte +++ b/app/src/lib/graph-interface/node/Node.svelte @@ -10,7 +10,6 @@ import { colors } from "../graph/colors.svelte"; import { appSettings } from "$lib/settings/app-settings.svelte"; - const graph = getGraphManager(); const graphState = getGraphState(); type Props = { @@ -37,14 +36,11 @@ const height = graphState.getNodeHeight(node.type); $effect(() => { - if (!node?.tmp) node.tmp = {}; - node.tmp.mesh = meshRef; - }); - - onMount(() => { if (!node.tmp) node.tmp = {}; - node.tmp.mesh = meshRef; - graphState.updateNodePosition(node); + if (meshRef && !node.tmp?.mesh) { + node.tmp.mesh = meshRef; + graphState.updateNodePosition(node); + } });