Skip to content

Commit

Permalink
fix: set a default voting period when not set by the space
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Dec 4, 2024
1 parent 180b681 commit dd6c04c
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions apps/ui/src/views/Space/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { validateForm } from '@/helpers/validation';
import { getNetwork, offchainNetworks } from '@/networks';
import { Contact, Space, Transaction, VoteType } from '@/types';
const DEFAULT_VOTING_DELAY = 60 * 60 * 24 * 3;
const TITLE_DEFINITION = {
type: 'string',
title: 'Title',
Expand Down Expand Up @@ -173,6 +175,16 @@ const proposalLimitReached = computed(
const propositionPower = computed(() => getPropositionPower(props.space));
const proposalStart = computed(
() => Math.floor(Date.now() / 1000) + props.space.voting_delay
);
const proposalMinEnd = computed(
() =>
proposalStart.value +
(props.space.min_voting_period || DEFAULT_VOTING_DELAY)
);
async function handleProposeClick() {
if (!proposal.value) return;
Expand Down Expand Up @@ -214,10 +226,6 @@ async function handleProposeClick() {
);
} else {
const appName = (route.query.app as LocationQueryValue) || '';
const currentTime = Math.floor(Date.now() / 1000);
const start = currentTime + props.space.voting_delay;
const minEnd = start + props.space.min_voting_period;
const maxEnd = start + props.space.max_voting_period;
result = await propose(
props.space,
Expand All @@ -228,9 +236,9 @@ async function handleProposeClick() {
choices,
proposal.value.labels,
appName.length <= 128 ? appName : '',
start,
minEnd,
maxEnd,
proposalStart.value,
proposalMinEnd.value,
proposalMinEnd.value,
executions
);
}
Expand Down Expand Up @@ -566,7 +574,14 @@ watchEffect(() => {
/>
<div>
<h4 class="eyebrow mb-2.5" v-text="'Timeline'" />
<ProposalTimeline :data="space" />
<ProposalTimeline
:data="{
...space,
start: proposalStart,
min_end: proposalMinEnd,
max_end: proposalMinEnd
}"
/>
</div>
</div>
</Affix>
Expand Down

0 comments on commit dd6c04c

Please sign in to comment.