From fa2c4bed8e2fd84c5eeca57f8f2ff8b87030a58b Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Wed, 2 Nov 2022 13:12:40 +0330 Subject: [PATCH] fix(storage): clear cached keys --- packages/core/storage/src/storage.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/storage/src/storage.ts b/packages/core/storage/src/storage.ts index 0271b03d6..8f13efc5f 100644 --- a/packages/core/storage/src/storage.ts +++ b/packages/core/storage/src/storage.ts @@ -164,7 +164,7 @@ export class AlwatrStorage { this._logger.logMethodArgs('set', documentObject._id); const oldData = this._storage[documentObject._id]; - if (oldData == null) this._keys = null; // Clear cached keys on new docId + if (oldData == null) this._keys = null; // Clear cached keys if (fastInstance !== true) { documentObject = JSON.parse(JSON.stringify(documentObject)); @@ -199,6 +199,10 @@ export class AlwatrStorage { } // else delete this._storage[documentId]; + + // Clear cached keys + this._keys = null; + this.save(); return true; } @@ -267,5 +271,8 @@ export class AlwatrStorage { this.forceSave(); } this._storage = {}; + + // Clear cached keys + this._keys = null; } }