diff --git a/package.json b/package.json index 8642c28..b6a900d 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "emoji-regex": "^10.3.0", "http-status-codes": "^2.3.0", "localforage": "^1.10.0", + "localforage-getitems": "^1.4.2", "lodash": "^4.17.21", "lucide": "^0.298.0", "mime-types": "^2.1.35", diff --git a/src/localdb.ts b/src/localdb.ts index f91db0c..6833b7c 100644 --- a/src/localdb.ts +++ b/src/localdb.ts @@ -1,4 +1,6 @@ import localforage from "localforage"; +import { extendPrototype } from "localforage-getitems"; +extendPrototype(localforage); export type LocalForage = typeof localforage; import { nanoid } from "nanoid"; import { requireApiVersion, TAbstractFile, TFile, TFolder } from "obsidian"; @@ -434,13 +436,12 @@ export const getAllPrevSyncRecordsByVaultAndProfile = async ( vaultRandomID: string, profileID: string ) => { - // console.debug('inside getAllPrevSyncRecordsByVaultAndProfile') - const keys = await db.prevSyncRecordsTbl.keys(); - // console.debug(`inside getAllPrevSyncRecordsByVaultAndProfile, keys=${keys}`) const res: Entity[] = []; - for (const key of keys) { + const kv: Record = + await db.prevSyncRecordsTbl.getItems(); + for (const key of Object.getOwnPropertyNames(kv)) { if (key.startsWith(`${vaultRandomID}\t${profileID}\t`)) { - const val: Entity | null = await db.prevSyncRecordsTbl.getItem(key); + const val = kv[key]; if (val !== null) { res.push(val); } diff --git a/src/sync.ts b/src/sync.ts index c9d32a7..0557c73 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -1369,9 +1369,9 @@ export const doActualSync = async ( for (let j = 0; j < operations.length; ++j) { const singleLevelOps = operations[j]; - console.debug( - `singleLevelOps=${JSON.stringify(singleLevelOps, null, 2)}` - ); + // console.debug( + // `singleLevelOps=${JSON.stringify(singleLevelOps, null, 2)}` + // ); if (singleLevelOps === undefined || singleLevelOps === null) { continue; } @@ -1385,9 +1385,9 @@ export const doActualSync = async ( const key = val.key; const fn = async () => { - console.debug( - `start syncing "${key}" with plan ${JSON.stringify(val)}` - ); + // console.debug( + // `start syncing "${key}" with plan ${JSON.stringify(val)}` + // ); if (callbackSyncProcess !== undefined) { await callbackSyncProcess( @@ -1412,7 +1412,7 @@ export const doActualSync = async ( cipher ); - console.debug(`finished ${key}`); + // console.debug(`finished ${key}`); }; queue.add(fn).catch((e) => {