From 148b20978cff9ce3a2321bee6a91582d075d5bf0 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Thu, 12 Oct 2017 22:23:06 +0200 Subject: [PATCH] Backport stable #6730 - Fixes Badges (#6731) * Fix badges not showing up * Always fetch meta data first [badges] --- .../providers/certifications/certifiers.monitor.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/src/redux/providers/certifications/certifiers.monitor.js b/js/src/redux/providers/certifications/certifiers.monitor.js index 208b728b37a..d8ea5e451f6 100644 --- a/js/src/redux/providers/certifications/certifiers.monitor.js +++ b/js/src/redux/providers/certifications/certifiers.monitor.js @@ -206,7 +206,7 @@ export default class CertifiersMonitor { // Fetch the address, name and owner in one batch return querier(this.api, { address: instance.address, from, limit }, instance.badge) .then((results) => { - this.certifiers = results + const certifiers = results .map(([ address, name, owner ], index) => ({ address, owner, id: index + from, @@ -225,7 +225,7 @@ export default class CertifiersMonitor { }, {}); // Fetch the meta-data in serie - return Object.values(this.certifiers).reduce((promise, certifier) => { + return Object.values(certifiers).reduce((promise, certifier) => { return promise.then(() => badgeReg.fetchMeta(certifier.id)) .then((meta) => { this.certifiers[certifier.id] = { ...certifier, ...meta }; @@ -274,8 +274,6 @@ export default class CertifiersMonitor { .then((certified) => { const { id, title, icon, name } = certifier; - this.fetchedAccounts[address] = true; - if (!certified) { return this.store.dispatch(removeCertification(address, id)); } @@ -283,7 +281,10 @@ export default class CertifiersMonitor { log.debug('seen as certified', { address, id, name, icon }); this.store.dispatch(addCertification(address, id, name, title, icon)); }); - }, Promise.resolve()); + }, Promise.resolve()) + .then(() => { + this.fetchedAccounts[address] = true; + }); } setCertifiersFilter () {