From a2879f170fe2e30589cbd8d1bf4b7129580119a2 Mon Sep 17 00:00:00 2001 From: Alberto Gualis Date: Tue, 31 Oct 2023 17:04:33 +0100 Subject: [PATCH] Fix: reload multivoting request on account change --- .../pages/vebal/LMVoting/LMVoting.vue | 19 ++++++++++++++++--- .../pages/vebal/providers/voting.provider.ts | 5 ++++- src/composables/useVotingPools.ts | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/components/contextual/pages/vebal/LMVoting/LMVoting.vue b/src/components/contextual/pages/vebal/LMVoting/LMVoting.vue index 0975213aee..37f562389c 100644 --- a/src/components/contextual/pages/vebal/LMVoting/LMVoting.vue +++ b/src/components/contextual/pages/vebal/LMVoting/LMVoting.vue @@ -22,12 +22,14 @@ import { useLMVotingFilters } from './composables/useLMVotingFilters'; /** * COMPOSABLES */ +const { account } = useWeb3(); const { votingPools, unallocatedVotes, votingPeriodEnd, votingPeriodLastHour, isRefetchingVotingPools, + resetVotingPools, } = useVotingPools(); const { veBalLockTooShort, veBalExpired, hasLock, hasExpiredLock } = useVeBalLockInfo(); @@ -46,6 +48,7 @@ const { hasSubmittedVotes, hasAllVotingPowerTimeLocked, loadRequestWithExistingVotes, + isVotingRequestLoaded, } = useVoting(); const { @@ -120,16 +123,26 @@ watch( { deep: true } ); -watch(isLoading, async () => { +watch(isLoading, async newValue => { // Load votingRequest once the voting list and the expired gauges were loaded - loadRequestWithExistingVotes(votingPools.value); + if (!newValue) { + loadRequestWithExistingVotes(votingPools.value); + } }); + watch(isRefetchingVotingPools, async () => { // Reload votingRequest if refetching after coming back from a successful voting - if (isVotingCompleted.value) { + if (isVotingCompleted.value || !isVotingRequestLoaded) { loadRequestWithExistingVotes(votingPools.value); } }); +watch(account, (_, prevAccount) => { + if (prevAccount) { + // Clear voting request on account change + isVotingRequestLoaded.value = false; + resetVotingPools(); + } +});