-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than that it looks good to me.
…into fix-refresh-scores
…/sx-monorepo into fix-refresh-scores
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this function to where it usually is (after computed, above lifecycle methods)?
Also what do you think about refetching proposal instead of triggering hard page reload?
diff --git a/apps/ui/src/components/ProposalResults.vue b/apps/ui/src/components/ProposalResults.vue
index 702f0cd2..34bf3f17 100644
--- a/apps/ui/src/components/ProposalResults.vue
+++ b/apps/ui/src/components/ProposalResults.vue
@@ -13,21 +13,6 @@ 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;
@@ -42,6 +27,8 @@ const props = withDefaults(
}
);
+const proposalsStore = useProposalsStore();
+
const displayAllChoices = ref(false);
const totalProgress = computed(() => quorumProgress(props.proposal));
@@ -111,6 +98,26 @@ const isFinalizing = computed(() => {
);
});
+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) {
+ proposalsStore.reset(props.proposal.space.id, props.proposal.network);
+ await proposalsStore.fetchProposal(
+ props.proposal.space.id,
+ props.proposal.id,
+ props.proposal.network
+ );
+ }
+ } catch (e) {
+ console.warn('Failed to refresh scores', e);
+ }
+}
+
onMounted(() => {
if (offchainNetworks.includes(props.proposal.network) && isFinalizing.value) {
refreshScores();
Nice idea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partial tACK (haven't tested on actual isFinalizing
proposal).
Summary
Closes: https://github.com/snapshot-labs/workflow/issues/347
How to test