From aa6909ff990e3c86605d47180fd59dcef958fc7a Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Thu, 12 Oct 2017 22:26:57 +0200 Subject: [PATCH] Backport beta #6730 - Fixes Badges (#6732) * 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 208b728b3..d8ea5e451 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 () {