From 0abd40a52a7996a416771176a272c240e245548e Mon Sep 17 00:00:00 2001 From: ChaituVR Date: Sat, 4 Jan 2025 00:11:43 +0530 Subject: [PATCH 1/4] fix: refresh scores once proposal is closed --- apps/ui/src/components/ProposalResults.vue | 20 +++++++++++++++++++ .../src/networks/common/graphqlApi/index.ts | 3 +++ 2 files changed, 23 insertions(+) diff --git a/apps/ui/src/components/ProposalResults.vue b/apps/ui/src/components/ProposalResults.vue index 78617a6e8..c6109e404 100644 --- a/apps/ui/src/components/ProposalResults.vue +++ b/apps/ui/src/components/ProposalResults.vue @@ -6,12 +6,26 @@ import { quorumProgress } from '@/helpers/quorum'; import { _n, _p, _vp } from '@/helpers/utils'; +import { getNetwork } from '@/networks'; import { Proposal as ProposalType } from '@/types'; const DEFAULT_MAX_CHOICES = 6; const SHUTTER_URL = 'https://www.shutter.network/shielded-voting'; +async function refreshScores() { + try { + const network = getNetwork(props.proposal.network); + const hubUrl = network.api.apiUrl.replace('/graphql', ''); + const response = await fetch(`${hubUrl}/api/scores/${props.proposal.id}`); + const result = await response.json(); + + if (result.result === true) { + window.location.reload(); + } + } catch (e) {} +} + const props = withDefaults( defineProps<{ proposal: ProposalType; @@ -94,6 +108,12 @@ const isFinalizing = computed(() => { ['passed', 'executed', 'rejected'].includes(props.proposal.state) ); }); + +onMounted(() => { + if (props.proposal.network === 's' && isFinalizing.value) { + refreshScores(); + } +});