mirror of
https://github.com/calfmoon/node-factor.git
synced 2026-07-22 05:42:24 +00:00
fix(calc): stop calcLoop if graph is closed
This commit is contained in:
parent
bdf1a746b2
commit
9155817954
1 changed files with 7 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ import SampleSettingTab from "./settings";
|
|||
|
||||
export default class NodeFactor extends Plugin {
|
||||
settings: NodeFactorSettings;
|
||||
updateLoop: boolean;
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
|
|
@ -15,7 +16,11 @@ export default class NodeFactor extends Plugin {
|
|||
const leaf = this.app.workspace
|
||||
.getLeavesOfType("graph")
|
||||
.first();
|
||||
if (!leaf) return;
|
||||
if (!leaf) {
|
||||
this.updateLoop = false;
|
||||
return;
|
||||
}
|
||||
this.updateLoop = true;
|
||||
|
||||
// @ts-ignore
|
||||
const nodes: ObsidianNode[] = leaf.view.renderer.nodes;
|
||||
|
|
@ -43,7 +48,7 @@ export default class NodeFactor extends Plugin {
|
|||
const weight = this.calcNodeWeight(node, treeOptimizeMap);
|
||||
node.weight = weight;
|
||||
});
|
||||
this.calcLoop(nodes);
|
||||
if (this.updateLoop) this.calcLoop(nodes);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue