From 58add6c5e95469fde148e7792fddc4976e9593d1 Mon Sep 17 00:00:00 2001 From: cdrani Date: Wed, 15 May 2024 16:42:29 -0600 Subject: [PATCH] fix: early return cache data if value object empty --- src/stores/cache.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stores/cache.js b/src/stores/cache.js index 0d2b2f02..4aba8333 100644 --- a/src/stores/cache.js +++ b/src/stores/cache.js @@ -6,6 +6,10 @@ export default class CacheStore { return this.#cache } + isEmpty(obj) { + return Object.keys(obj).length === 0 && obj.constructor === Object; + } + getKey(key) { const result = this.#cache.getItem(key) try { return JSON.parse(result) } @@ -14,7 +18,7 @@ export default class CacheStore { getValue({ key, value }) { const result = this.getKey(key) - if (result) return result + if (result && this.isEmpty(value)) return result return this.update({ key, value }) }