From 5e5929565ebba1a35cf7cf993d9996da6fe7038f Mon Sep 17 00:00:00 2001 From: benji7425 Date: Sat, 29 Jul 2017 20:40:55 +0100 Subject: [PATCH] Fix mistake whereby the caches for each guild would update synchronously --- app/models/guild-data.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/models/guild-data.js b/app/models/guild-data.js index 53941dd..82de0f9 100644 --- a/app/models/guild-data.js +++ b/app/models/guild-data.js @@ -8,14 +8,12 @@ module.exports = class GuildData { } cachePastPostedLinks() { - let i = 0; - const recurse = () => { - this.feeds[i++].cachePastPostedLinks(this) - .catch(Util.dateError) - .then(recurse); - if (i > this.feeds.length) - return Promise.resolve(); - }; + const promises = []; + + this.feeds.forEach(feed => { + promises.push(feed.cachePastPostedLinks(this).catch(Util.dateError)); + }); + return Promise.all(promises); } }; \ No newline at end of file