From aa7c910f4b384cd56c23cb94b7b72b05ae032021 Mon Sep 17 00:00:00 2001 From: alisa Date: Tue, 25 Apr 2023 15:25:02 +0800 Subject: [PATCH] fix: Governance Tally no data --- src/modules/[chain]/gov/[proposal_id].vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modules/[chain]/gov/[proposal_id].vue b/src/modules/[chain]/gov/[proposal_id].vue index b038114b..c82a0390 100644 --- a/src/modules/[chain]/gov/[proposal_id].vue +++ b/src/modules/[chain]/gov/[proposal_id].vue @@ -2,7 +2,7 @@ import ObjectElement from '@/components/dynamic/ObjectElement.vue'; import { useBaseStore, useFormatter, useGovStore, useStakingStore } from '@/stores'; import type { GovProposal, GovVote, PaginabledAccounts, PaginatedProposalDeposit, PaginatedProposalVotes, Pagination } from '@/types'; -import { ref } from 'vue'; +import { ref , reactive} from 'vue'; import Countdown from '@/components/Countdown.vue'; import { computed } from '@vue/reactivity'; @@ -12,7 +12,16 @@ const props = defineProps(["proposal_id", "chain"]); const proposal = ref({} as GovProposal) const format = useFormatter() const store = useGovStore() -store.fetchProposal(props.proposal_id).then((x) => proposal.value = x.proposal) +store.fetchProposal(props.proposal_id).then((res) => { + const proposalDetail = reactive(res.proposal) + // when status under the voting, final_tally_result are no data, should request fetchTally + if (res.proposal?.status === 'PROPOSAL_STATUS_VOTING_PERIOD'){ + store.fetchTally(props.proposal_id).then((tallRes)=>{ + proposalDetail.final_tally_result = tallRes?.tally + }) + } + proposal.value = proposalDetail +}) const color = computed(() => { if (proposal.value.status==='PROPOSAL_STATUS_PASSED') { @@ -78,6 +87,7 @@ const upgradeCountdown = computed((): number => { }) const total = computed(()=> { + console.log(proposal.value, 'proposal.value') const tally = proposal.value.final_tally_result let sum = 0 if(tally) {