mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2025-12-13 09:45:56 +00:00
Indeed, even though if this changeset is mostly another nightmare. It might be in beta for a while.
23 lines
909 B
TypeScript
23 lines
909 B
TypeScript
import { AbstractModule } from "../AbstractModule";
|
|
import { PouchDB } from "../../lib/src/pouchdb/pouchdb-browser";
|
|
import type { LiveSyncCore } from "../../main";
|
|
|
|
export class ModulePouchDB extends AbstractModule {
|
|
_createPouchDBInstance<T extends object>(
|
|
name?: string,
|
|
options?: PouchDB.Configuration.DatabaseConfiguration
|
|
): PouchDB.Database<T> {
|
|
const optionPass = options ?? {};
|
|
if (this.settings.useIndexedDBAdapter) {
|
|
optionPass.adapter = "indexeddb";
|
|
//@ts-ignore :missing def
|
|
optionPass.purged_infos_limit = 1;
|
|
return new PouchDB(name + "-indexeddb", optionPass);
|
|
}
|
|
return new PouchDB(name, optionPass);
|
|
}
|
|
onBindFunction(core: LiveSyncCore, services: typeof core.services): void {
|
|
services.database.handleCreatePouchDBInstance(this._createPouchDBInstance.bind(this));
|
|
}
|
|
}
|