Skip to content

Commit

Permalink
add wait for Obsidian Sync before loading entities
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpetro committed Aug 1, 2024
1 parent b13a7cc commit 94fcf0a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sc_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ export class ScEnv {
}
// load one at a time to re-use embed models (smart-entities-2)
async init_entities() {
const obsidian_sync_instance = this.main.app?.internalPlugins?.plugins?.sync?.instance;
while(obsidian_sync_instance?.syncing){
this.waiting_for_obsidian_sync = true;
console.log("Smart Connections: Waiting for Obsidian Sync to finish");
await new Promise(r => setTimeout(r, 1000));
}
this.waiting_for_obsidian_sync = false;
if(this.plugin.is_initializing_entities) return console.log('already init entities'); // Check if already initializing
this.plugin.is_initializing_entities = true; // Set flag to true to indicate initialization has started
this.smart_sources = new this.collection_types.SmartSources(this, { adapter_class: this.sc_adapter_class, custom_collection_name: 'smart_sources' });
Expand Down

0 comments on commit 94fcf0a

Please sign in to comment.