mirror of
https://github.com/calfmoon/node-factor.git
synced 2026-07-22 05:42:24 +00:00
perf(update): prevent graph update from running multiple times at once
This commit is contained in:
parent
777de23d9a
commit
783607292d
1 changed files with 3 additions and 1 deletions
|
|
@ -40,6 +40,7 @@ export default class NodeFactor extends Plugin {
|
||||||
async onunload() {}
|
async onunload() {}
|
||||||
|
|
||||||
private sizeCache: Map<string, number> = new Map();
|
private sizeCache: Map<string, number> = new Map();
|
||||||
|
private timeoutId: NodeJS.Timeout;
|
||||||
private updateGraph() {
|
private updateGraph() {
|
||||||
const leaf = this.app.workspace.getLeavesOfType("graph").first();
|
const leaf = this.app.workspace.getLeavesOfType("graph").first();
|
||||||
// don't run if graph page isn't loaded
|
// 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
|
// Slight delay in calculations is needed to fix node size
|
||||||
// if graph view is initially opened when opening obsidian
|
// if graph view is initially opened when opening obsidian
|
||||||
setTimeout(() => {
|
clearTimeout(this.timeoutId);
|
||||||
|
this.timeoutId = setTimeout(() => {
|
||||||
nodes.forEach((node, _i) => {
|
nodes.forEach((node, _i) => {
|
||||||
let weight = 0;
|
let weight = 0;
|
||||||
if (this.sizeCache.get(node.id) != undefined) {
|
if (this.sizeCache.get(node.id) != undefined) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue