Skip to content

Commit

Permalink
fix: move post vote actions to the vote modal (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e authored Aug 13, 2024
1 parent 58fc38b commit 136bc71
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
19 changes: 17 additions & 2 deletions apps/ui/src/components/Modal/Vote.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { getChoiceText, getFormattedVotingPower } from '@/helpers/utils';
import { getValidator } from '@/helpers/validation';
import { offchainNetworks } from '@/networks';
import { Choice, Proposal } from '@/types';
const REASON_DEFINITION = {
Expand Down Expand Up @@ -29,6 +30,7 @@ const {
fetch: fetchVotingPower,
reset: resetVotingPower
} = useVotingPower();
const proposalsStore = useProposalsStore();
const { loadVotes, votes } = useAccount();
const loading = ref(false);
Expand Down Expand Up @@ -66,8 +68,21 @@ async function handleSubmit() {
try {
await vote(props.proposal, props.choice, form.value.reason);
emit('voted');
emit('close');
try {
// TODO: Quick fix only for offchain proposals, need a more complete solution for onchain proposals
if (offchainNetworks.includes(props.proposal.network)) {
proposalsStore.fetchProposal(
props.proposal.space.id,
props.proposal.id,
props.proposal.network
);
await loadVotes(props.proposal.network, [props.proposal.space.id]);
}
} finally {
emit('voted');
emit('close');
}
} finally {
loading.value = false;
}
Expand Down
17 changes: 1 addition & 16 deletions apps/ui/src/views/Proposal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,8 @@ async function handleVoteClick(choice: Choice) {
}
async function handleVoteSubmitted() {
if (!proposal.value) return;
selectedChoice.value = null;
try {
// TODO: Quick fix only for offchain proposals, need a more complete solution for onchain proposals
if (offchainNetworks.includes(proposal.value.network)) {
proposalsStore.fetchProposal(
spaceAddress.value!,
id.value,
networkId.value!
);
await loadVotes(proposal.value.network, [proposal.value.space.id]);
}
} finally {
editMode.value = false;
}
editMode.value = false;
}
function handleFetchVotingPower() {
Expand Down

0 comments on commit 136bc71

Please sign in to comment.