mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-02-25 13:38:49 +00:00
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import { $msg } from "../../lib/src/common/i18n";
|
|
import { LiveSyncLocalDB } from "../../lib/src/pouchdb/LiveSyncLocalDB.ts";
|
|
import { initializeStores } from "../../common/stores.ts";
|
|
import { AbstractModule } from "../AbstractModule.ts";
|
|
import type { ICoreModule } from "../ModuleTypes.ts";
|
|
|
|
export class ModuleLocalDatabaseObsidian extends AbstractModule implements ICoreModule {
|
|
$everyOnloadStart(): Promise<boolean> {
|
|
return Promise.resolve(true);
|
|
}
|
|
async $$openDatabase(): Promise<boolean> {
|
|
if (this.localDatabase != null) {
|
|
await this.localDatabase.close();
|
|
}
|
|
const vaultName = this.core.$$getVaultName();
|
|
this._log($msg("moduleLocalDatabase.logWaitingForReady"));
|
|
this.core.localDatabase = new LiveSyncLocalDB(vaultName, this.core);
|
|
initializeStores(vaultName);
|
|
return await this.localDatabase.initializeDatabase();
|
|
}
|
|
|
|
$$isDatabaseReady(): boolean {
|
|
return this.localDatabase != null && this.localDatabase.isReady;
|
|
}
|
|
}
|