Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refresh scores once proposal is closed #1077

Merged
merged 9 commits into from
Jan 6, 2025
20 changes: 20 additions & 0 deletions apps/ui/src/components/ProposalResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
ChaituVR marked this conversation as resolved.
Show resolved Hide resolved
}

const props = withDefaults(
defineProps<{
proposal: ProposalType;
Expand Down Expand Up @@ -94,6 +108,12 @@ const isFinalizing = computed(() => {
['passed', 'executed', 'rejected'].includes(props.proposal.state)
);
});

onMounted(() => {
if (props.proposal.network === 's' && isFinalizing.value) {
refreshScores();
}
ChaituVR marked this conversation as resolved.
Show resolved Hide resolved
});
</script>

<template>
Expand Down