From 351956283e36da1e7375f9e3090923b0c8c60e9c Mon Sep 17 00:00:00 2001 From: Wan <495709+wa0x6e@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:40:44 +0800 Subject: [PATCH] fix: fix proposition power to updating on account change (#1011) --- apps/ui/src/composables/usePropositionPower.ts | 2 +- apps/ui/src/views/Space/Editor.vue | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/ui/src/composables/usePropositionPower.ts b/apps/ui/src/composables/usePropositionPower.ts index e8cc15cb5..450a8bf0f 100644 --- a/apps/ui/src/composables/usePropositionPower.ts +++ b/apps/ui/src/composables/usePropositionPower.ts @@ -36,5 +36,5 @@ export function usePropositionPower() { } ); - return { fetch, get }; + return { fetch, get, reset }; } diff --git a/apps/ui/src/views/Space/Editor.vue b/apps/ui/src/views/Space/Editor.vue index 10c360cfb..3c5b1a01c 100644 --- a/apps/ui/src/views/Space/Editor.vue +++ b/apps/ui/src/views/Space/Editor.vue @@ -47,8 +47,11 @@ const { reset } = useWalletConnectTransaction(); const proposalsStore = useProposalsStore(); -const { get: getPropositionPower, fetch: fetchPropositionPower } = - usePropositionPower(); +const { + get: getPropositionPower, + fetch: fetchPropositionPower, + reset: resetPropositionPower +} = usePropositionPower(); const { strategiesWithTreasuries } = useTreasuries(props.space); const termsStore = useTermsStore(); @@ -286,9 +289,13 @@ function handleFetchPropositionPower() { } watch( - () => web3.value.account, - toAccount => { - if (!toAccount) return; + [() => web3.value.account, () => web3.value.authLoading], + ([toAccount, toAuthLoading], [fromAccount]) => { + if (fromAccount && toAccount && fromAccount !== toAccount) { + resetPropositionPower(); + } + + if (toAuthLoading || !toAccount) return; handleFetchPropositionPower(); },