From 9a39d87c3fac215e8466a8fafc2a93df9fbb8682 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 29 Nov 2022 20:34:30 +0800 Subject: [PATCH] filter useless loading --- src/views/Uptime.vue | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/views/Uptime.vue b/src/views/Uptime.vue index 950e2565..65331893 100644 --- a/src/views/Uptime.vue +++ b/src/views/Uptime.vue @@ -277,6 +277,9 @@ export default { }) return Object.values(valCounter).sort((a, b) => b.counter - a.counter) }, + h() { + return this.height + }, }, created() { const cached = JSON.parse(getCachedValidators(this.$route.params.chain)) @@ -323,13 +326,15 @@ export default { const blocks = [] // update height let promise = Promise.resolve() - for (let i = height - 1; i > height - 50; i -= 1) { + for (let i = height - 1; i > height - 48; i -= 1) { blocks.unshift({ sigs: {}, height: i > 0 ? i : 0 }) - if (i > height - 48 && i > 0) { - promise = promise.then(() => new Promise(resolve => { + promise = promise.then(() => new Promise(resolve => { + if (i > this.blocks[0].height && i > 0) { // filter useless loading this.fetch_status(i, resolve) - })) - } + } else { + resolve() + } + })) } const sigs = this.initColor() @@ -390,8 +395,8 @@ export default { res.block.last_commit.signatures.forEach(x => { if (x.validator_address) sigs[x.validator_address] = 'bg-success' }) - this.height = res.block.header.height - if (Number(this.height) % 100 === 0) { // update the missing number each 100 + this.height = Number(res.block.header.height) + if (this.height % 100 === 0) { // update the missing number each 100 this.fetchMissingInfo() } const block = this.blocks.find(b => b.height === res.block.last_commit.height)