From 84267708659e3e9bb2f8eb3b08d8923f235e8953 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Mon, 27 Sep 2021 17:19:25 +0530 Subject: [PATCH] fix(CachedManager): return updated data when cache is false (#6685) --- src/managers/CachedManager.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/managers/CachedManager.js b/src/managers/CachedManager.js index f532db68e..0f7e91407 100644 --- a/src/managers/CachedManager.js +++ b/src/managers/CachedManager.js @@ -45,8 +45,15 @@ class CachedManager extends DataManager { _add(data, cache = true, { id, extras = [] } = {}) { const existing = this.cache.get(id ?? data.id); - if (cache) existing?._patch(data); - if (existing) return existing; + if (existing) { + if (cache) { + existing._patch(data); + return existing; + } + const clone = existing._clone(); + clone._patch(data); + return clone; + } const entry = this.holds ? new this.holds(this.client, data, ...extras) : data; if (cache) this.cache.set(id ?? entry.id, entry);