Upgrading to the PouchDb indexedDb adapter while testing signals in web workers...

This commit is contained in:
vdv committed 2023-02-11 11:31:32 +01:00
1 parent e73497265f
commit 4a4ebdff50
11 files changed
+362 -5

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ import getUri from '../lib/ids';
export const initialAccount = {
id: 'initial',
name: '???',
localDb: 'dyomedea',
localDb: '_dyomedea_',
};
export const getAccounts = async () => {
+22 -2
View File
@@ -1,5 +1,6 @@
import _ from 'lodash';
import PouchDB from 'pouchdb';
import indexeddb from 'pouchdb-adapter-indexeddb';
import uri from '../lib/ids';
import { toHex } from '../lib/to-hex';
import {
@@ -11,6 +12,8 @@ import {
import changeHandler from './change-handler';
import { getSettings, putSettings } from './settings';
PouchDB.plugin(indexeddb);
const dbDefinitionId = uri('dbdef', {});
const currentDbDefinition = {
@@ -29,7 +32,8 @@ export const initDb = async (params: any) => {
console.log({ caller: 'initDb' });
if (globalThis.localDb === undefined) {
globalThis.localDb = new PouchDB('$local_dyomedea$', {
globalThis.localDb = new PouchDB('_local_dyomedea_', {
adapter: 'indexeddb',
auto_compaction: true,
revs_limit: 10,
});
@@ -55,10 +59,20 @@ export const initDb = async (params: any) => {
if (globalThis.db === undefined) {
globalThis.db = new PouchDB(currentAccount.localDb, {
auto_compaction: false,
adapter: 'indexeddb',
auto_compaction: true,
});
}
const db = globalThis.db;
const dbinfo = await db.info();
// db.compact();
console.log({
caller: 'initDb',
dbinfo,
activeTasks: PouchDB.activeTasks.list(),
storage: await navigator.storage.estimate(),
});
//
var previousDbDefinition = {
_id: dbDefinitionId,
type: dbDefinitionId,
@@ -150,5 +164,11 @@ export const initDb = async (params: any) => {
// changes.cancel();
console.log({
caller: 'initDb (end)',
dbinfo,
activeTasks: PouchDB.activeTasks.list(),
storage: await navigator.storage.estimate(),
});
globalThis.dbReady = true;
};
+1 -2
View File
@@ -1,7 +1,6 @@
import { cloneDeep, debounce, memoize, property, wrap } from 'lodash';
import { delay } from '../lib/delay';
import getUri from '../lib/ids';
import { appendToArray, putNewGpx } from './gpx';
import { putNewGpx } from './gpx';
import { getFamily, put } from './lib';
export const emptyRte: Rte = {