From 87752981234343d92763bc7205d5ea587b68d277 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sun, 30 Apr 2023 10:11:23 +0800 Subject: [PATCH] add live check --- src/modules/[chain]/uptime/index.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/modules/[chain]/uptime/index.vue b/src/modules/[chain]/uptime/index.vue index 57df43f3..79706972 100644 --- a/src/modules/[chain]/uptime/index.vue +++ b/src/modules/[chain]/uptime/index.vue @@ -13,6 +13,7 @@ const format = useFormatter(); const latest = ref({}) const commits = ref([] as Commit[]); const keyword = ref("") +const live = ref(true); const signingInfo = ref({}) @@ -22,6 +23,7 @@ const validators = computed(()=> { }) onMounted(() => { + live.value = true baseStore.fetchLatest().then(block => { latest.value = block commits.value.unshift(block.block.last_commit) @@ -30,11 +32,15 @@ onMounted(() => { // constructs sequence for loading blocks let promise = Promise.resolve() for (let i = height - 1; i > height - 50; i -= 1) { - if (i > height - 48 && i > 0) { - promise = promise.then(() => new Promise(resolve => { + if (i > height - 48) { + promise = promise.then(() => new Promise((resolve, reject) => { baseStore.fetchBlock(i).then((x) => { commits.value.unshift(x.block.last_commit) - resolve() + if(live.value) { + resolve() + } else { + reject() + } }) })) } @@ -49,6 +55,10 @@ onMounted(() => { }) }) +onUnmounted(() => { + live.value = false +}) +