Skip to content

Commit

Permalink
Only draw for new metadata once dataview indexing is finished.
Browse files Browse the repository at this point in the history
Fixes #12
  • Loading branch information
natefrisch01 committed Jan 16, 2024
1 parent 383ffaf commit cd44cb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ export default class GraphLinkTypesPlugin extends Plugin {
currentRenderer: ObsidianRenderer | null = null;
animationFrameId: number | null = null;
linkManager = new LinkManager();
indexReady = false;

// Lifecycle method called when the plugin is loaded
async onload(): Promise<void> {

// Check if the Dataview API is available
if (!this.api) {
console.error("Dataview plugin is not available.");
Expand All @@ -26,19 +28,18 @@ export default class GraphLinkTypesPlugin extends Plugin {
// @ts-ignore
this.registerEvent(this.app.metadataCache.on("dataview:index-ready", () => {
this.handleLayoutChange();
this.indexReady = true;
}));

// @ts-ignore
this.registerEvent(this.app.metadataCache.on("dataview:metadata-change", () => {
this.handleLayoutChange();
if (this.indexReady) {
this.handleLayoutChange();
}
}));

}





// Find the first valid graph renderer in the workspace
findRenderer(): ObsidianRenderer | null {
let graphLeaves = this.app.workspace.getLeavesOfType('graph');
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd44cb6

Please sign in to comment.