Skip to content

Commit cd44cb6

Browse files
committed
Only draw for new metadata once dataview indexing is finished.
Fixes natefrisch01#12
1 parent 383ffaf commit cd44cb6

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

main.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ export default class GraphLinkTypesPlugin extends Plugin {
99
currentRenderer: ObsidianRenderer | null = null;
1010
animationFrameId: number | null = null;
1111
linkManager = new LinkManager();
12+
indexReady = false;
1213

1314
// Lifecycle method called when the plugin is loaded
1415
async onload(): Promise<void> {
16+
1517
// Check if the Dataview API is available
1618
if (!this.api) {
1719
console.error("Dataview plugin is not available.");
@@ -26,19 +28,18 @@ export default class GraphLinkTypesPlugin extends Plugin {
2628
// @ts-ignore
2729
this.registerEvent(this.app.metadataCache.on("dataview:index-ready", () => {
2830
this.handleLayoutChange();
31+
this.indexReady = true;
2932
}));
3033

3134
// @ts-ignore
3235
this.registerEvent(this.app.metadataCache.on("dataview:metadata-change", () => {
33-
this.handleLayoutChange();
36+
if (this.indexReady) {
37+
this.handleLayoutChange();
38+
}
3439
}));
3540

3641
}
3742

38-
39-
40-
41-
4243
// Find the first valid graph renderer in the workspace
4344
findRenderer(): ObsidianRenderer | null {
4445
let graphLeaves = this.app.workspace.getLeavesOfType('graph');

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)