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/reset vote selection #4480

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/components/contextual/pages/vebal/LMVoting/LMVoting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -46,6 +48,7 @@ const {
hasSubmittedVotes,
hasAllVotingPowerTimeLocked,
loadRequestWithExistingVotes,
isVotingRequestLoaded,
} = useVoting();

const {
Expand Down Expand Up @@ -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();
}
});
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export function votingProvider() {
const {
votingPools,
votingGaugeAddresses,
isLoading: isLoadingVotingPools,
isLoadingVotingPools,
isRefetchingVotingPools,
} = useVotingPools();
const { data: expiredGauges, isLoading: isLoadingExpiredGauges } =
useExpiredGaugesQuery(votingGaugeAddresses);
Expand Down Expand Up @@ -222,6 +223,7 @@ export function votingProvider() {
isLoading,
isLoadingExpiredGauges,
isLoadingVotingPools,
isRefetchingVotingPools,
totalAllocatedWeight,
isRequestingTooMuchWeight,
isVotingRequestValid,
Expand All @@ -233,6 +235,7 @@ export function votingProvider() {
hasAllVotingPowerTimeLocked,
hasTimeLockedPools,
confirmedVotingRequest,
isVotingRequestLoaded,
getIsGaugeExpired,
toggleSelection,
isSelected,
Expand Down
3 changes: 2 additions & 1 deletion src/composables/useVotingPools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function useVotingPools() {

return {
totalVotes,
isLoading,
isLoadingVotingPools: isLoading,
isRefetchingVotingPools: votingPoolsQuery.isRefetching,
votingPools,
votingGauges,
Expand All @@ -103,5 +103,6 @@ export default function useVotingPools() {
votingPeriodLastHour,
votingPoolsQuery,
refetchVotingPools: votingPoolsQuery.refetch,
resetVotingPools: votingPoolsQuery.remove,
};
}