From 364b268b02b97d0ef0e8829b24c0a9b4c9128ea1 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 3 Aug 2021 11:08:55 +0800 Subject: [PATCH] Cancel fetch up on destroy --- src/views/Staking.vue | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/views/Staking.vue b/src/views/Staking.vue index 2a258753..dd506420 100644 --- a/src/views/Staking.vue +++ b/src/views/Staking.vue @@ -164,11 +164,9 @@ export default { console.log(identities) let promise = Promise.resolve() identities.forEach(item => { - if (this.islive) { - promise = promise.then(() => new Promise(resolve => { - this.avatar(item, resolve) - })) - } + promise = promise.then(() => new Promise(resolve => { + this.avatar(item, resolve) + })) }) }) }, @@ -201,19 +199,21 @@ export default { return 'primary' }, avatar(identity, resolve) { - keybase(identity).then(d => { - resolve() - console.log(identity) - if (Array.isArray(d.them) && d.them.length > 0) { - const pic = d.them[0].pictures - console.log('fetch new avatar:', pic) - if (pic) { - const validator = this.validators.find(u => u.description.identity === identity) - this.$set(validator, 'avatar', pic.primary.url) - this.$store.commit('cacheAvatar', { identity, url: pic.primary.url }) + if (this.islive) { + keybase(identity).then(d => { + resolve() + console.log(identity) + if (Array.isArray(d.them) && d.them.length > 0) { + const pic = d.them[0].pictures + console.log('fetch new avatar:', pic) + if (pic) { + const validator = this.validators.find(u => u.description.identity === identity) + this.$set(validator, 'avatar', pic.primary.url) + this.$store.commit('cacheAvatar', { identity, url: pic.primary.url }) + } } - } - }) + }) + } }, }, }