From 2b62eed10dae40dcee3ee6c78daa02573f5aa1cf Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 15 Dec 2021 10:18:58 -0300 Subject: [PATCH] decouple the tally fetch to its own action and refactor the claim button --- vue-app/src/components/ClaimButton.vue | 85 +++++++++++++++++--------- vue-app/src/store/action-types.ts | 1 + vue-app/src/store/actions.ts | 8 ++- 3 files changed, 62 insertions(+), 32 deletions(-) diff --git a/vue-app/src/components/ClaimButton.vue b/vue-app/src/components/ClaimButton.vue index 378e887ab..34918de70 100644 --- a/vue-app/src/components/ClaimButton.vue +++ b/vue-app/src/components/ClaimButton.vue @@ -1,5 +1,6 @@ diff --git a/vue-app/src/store/action-types.ts b/vue-app/src/store/action-types.ts index d4dd5b213..59bf82cb7 100644 --- a/vue-app/src/store/action-types.ts +++ b/vue-app/src/store/action-types.ts @@ -1,4 +1,5 @@ export const SELECT_ROUND = 'SELECT_ROUND' +export const LOAD_TALLY = 'LOAD_TALLY' export const LOAD_FACTORY_INFO = 'LOAD_FACTORY_INFO' export const LOAD_ROUND_INFO = 'LOAD_ROUND_INFO' export const LOAD_RECIPIENT_REGISTRY_INFO = 'LOAD_RECIPIENT_REGISTRY_INFO' diff --git a/vue-app/src/store/actions.ts b/vue-app/src/store/actions.ts index 5f5663756..f37878748 100644 --- a/vue-app/src/store/actions.ts +++ b/vue-app/src/store/actions.ts @@ -30,6 +30,7 @@ import { LOAD_FACTORY_INFO, LOAD_RECIPIENT_REGISTRY_INFO, LOAD_ROUND_INFO, + LOAD_TALLY, LOAD_USER_INFO, LOGIN_USER, LOGOUT_USER, @@ -92,8 +93,11 @@ const actions = { //TODO: update to take factory address as a parameter, default to env. variable const round = await getRoundInfo(roundAddress) commit(SET_CURRENT_ROUND, round) - if (round && round.status === RoundStatus.Finalized) { - const tally = await getTally(roundAddress) + }, + async [LOAD_TALLY]({ commit, state }) { + const currentRound = state.currentRound + if (currentRound && currentRound.status === RoundStatus.Finalized) { + const tally = await getTally(state.currentRoundAddress) commit(SET_TALLY, tally) } },