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
22 changes: 22 additions & 0 deletions apps/ui/src/components/ProposalResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,28 @@ import {
quorumProgress
} from '@/helpers/quorum';
import { _n, _p, _vp } from '@/helpers/utils';
import { getNetwork, offchainNetworks } 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) {
console.warn('Failed to refresh scores', e);
}
}

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

onMounted(() => {
if (offchainNetworks.includes(props.proposal.network) && isFinalizing.value) {
refreshScores();
}
});
</script>

<template>
Expand Down