From 783607292d3807e185469352a78118b6e31bfe02 Mon Sep 17 00:00:00 2001 From: "Kritagya Bhattarai (CalfMoon)" Date: Sat, 28 Mar 2026 18:28:06 +0545 Subject: [PATCH] perf(update): prevent graph update from running multiple times at once --- src/main.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 1ca4014..6b3f691 100644 --- a/src/main.ts +++ b/src/main.ts @@ -40,6 +40,7 @@ export default class NodeFactor extends Plugin { async onunload() {} private sizeCache: Map = new Map(); + private timeoutId: NodeJS.Timeout; private updateGraph() { const leaf = this.app.workspace.getLeavesOfType("graph").first(); // don't run if graph page isn't loaded @@ -51,7 +52,8 @@ export default class NodeFactor extends Plugin { // Slight delay in calculations is needed to fix node size // if graph view is initially opened when opening obsidian - setTimeout(() => { + clearTimeout(this.timeoutId); + this.timeoutId = setTimeout(() => { nodes.forEach((node, _i) => { let weight = 0; if (this.sizeCache.get(node.id) != undefined) {