Skip to content

Commit

Permalink
wait for Obsidian Sync notive in view
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpetro committed Aug 1, 2024
1 parent 94fcf0a commit 55d9a3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/smart_obsidian_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,25 @@ export class SmartObsidianView extends ItemView {
get env() { return this.plugin.env; }
get config() { return this.plugin.settings; }
render_template(template_name, data) {
// console.log("rendering template", template_name);
if (!this.templates[template_name]) throw new Error(`Template '${template_name}' not found.`);
return ejs.render(this.templates[template_name], data, { context: this.view_context });
}
get view_context() {
return {
// app: this.plugin.app,
attribution: this.templates.attribution,
get_icon: this.get_icon.bind(this),
settings: this.plugin.settings,
};
}
async wait_for_env_to_load() {
if (!this.env?.entities_loaded) {
// set loading message
this.containerEl.children[1].innerHTML = "Loading Smart Connections...";
// wait for entities to be initialized
while (!this.env?.entities_loaded){
const loading_msg = this.env.waiting_for_obsidian_sync ? "Waiting for Obsidian Sync to finish..." : "Loading Smart Connections...";
// set loading message
if(this.containerEl.children[1].innerHTML !== loading_msg){
this.containerEl.children[1].innerHTML = loading_msg;
}
await new Promise(r => setTimeout(r, 2000));
}
}
Expand Down

0 comments on commit 55d9a3e

Please sign in to comment.