Skip to content

Commit

Permalink
Merge pull request #11 from soonaverse/bugfix/1167-vote
Browse files Browse the repository at this point in the history
#1167 - Fix proposal voting
  • Loading branch information
adamunchained authored Jul 20, 2023
2 parents bca7172 + aac2a77 commit 38bc695
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ProposalStatusComponent implements OnInit {
}

public isComplete(): boolean {
if (!this.proposal) {
if (!this.proposal || !this.proposal.settings?.endDate) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export class TokenVoteComponent implements OnInit, OnDestroy {
}
const params: any = {
uid: this.proposal.uid,
values: [this.answer.value],
value: this.answer.value,
};

if (this.voteTypeControl.value === VoteType.NATIVE_TOKEN) {
Expand Down
26 changes: 12 additions & 14 deletions src/app/pages/proposal/pages/overview/overview.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,21 @@ export class OverviewPage implements OnInit {
return;
}

if (!(this.voteControl.value > -1)) {
if (!this.voteControl.value || !(this.voteControl.value > -1)) {
this.nzNotification.error('', 'Please select option first!');
return;
}

await this.auth.sign(
{
uid: this.data.proposal$.value.uid,
values: [this.voteControl.value],
},
(sc, finish) => {
this.notification
.processRequest(this.proposalApi.vote(sc), 'Voted.', finish)
.subscribe(() => {
// none.
});
},
);
const params = {
uid: this.data.proposal$.value.uid,
value: this.voteControl.value,
};
await this.auth.sign(params, (sc, finish) => {
this.notification
.processRequest(this.proposalApi.vote(sc), 'Voted.', finish)
.subscribe(() => {
// none.
});
});
}
}
2 changes: 1 addition & 1 deletion src/app/pages/proposal/pages/proposal/proposal.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class ProposalPage implements OnInit, OnDestroy {

// Get badges to show.
const awards: Award[] = [];
if (p.settings.awards?.length) {
if (p.settings?.awards?.length) {
for (const a of p.settings.awards) {
const award: Award | undefined = await firstValueFrom(this.awardApi.listen(a));
if (award) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/proposal/services/helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class HelperService {
}

public isComplete(proposal?: Proposal | null): boolean {
if (!proposal) {
if (!proposal || !proposal.settings?.endDate) {
return false;
}

Expand Down

0 comments on commit 38bc695

Please sign in to comment.