Skip to content

Commit

Permalink
fix(CachedManager): return updated data when cache is false (#6685)
Browse files Browse the repository at this point in the history
  • Loading branch information
iShibi committed Sep 27, 2021
1 parent 79b1b20 commit 8426770
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/managers/CachedManager.js
Expand Up @@ -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);
Expand Down

0 comments on commit 8426770

Please sign in to comment.