mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-04-01 06:35:17 +00:00
- Now we can switch the database adapter between IndexedDB and IDB without rebuilding (#747). - No longer checking for the adapter by `Doctor`. ### Changes - The default adapter is reverted to IDB to avoid memory leaks (#747). ### Fixed (?) - Reverted QR code library to v1.4.4 (To make sure #752).
24 lines
984 B
TypeScript
24 lines
984 B
TypeScript
import { AbstractModule } from "../AbstractModule";
|
|
import { PouchDB } from "../../lib/src/pouchdb/pouchdb-browser";
|
|
import type { LiveSyncCore } from "../../main";
|
|
import { ExtraSuffixIndexedDB } from "../../lib/src/common/types";
|
|
|
|
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 + ExtraSuffixIndexedDB, optionPass);
|
|
}
|
|
return new PouchDB(name, optionPass);
|
|
}
|
|
onBindFunction(core: LiveSyncCore, services: typeof core.services): void {
|
|
services.database.handleCreatePouchDBInstance(this._createPouchDBInstance.bind(this));
|
|
}
|
|
}
|