Skip to content

Commit

Permalink
fix: wrong vote type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AMIRKHANEF committed Nov 2, 2024
1 parent 5ce94ed commit fa70422
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,18 @@ export async function getReferendumCommentsSS (chainName: string, refId: string
const votes = await votesResponse.json() as VoteSS[];

// Helper function to determine the vote decision
const voteInformation = (address: string): string => {
const voteInformation = (address: string): string | null => {
const vote = votes.find(({ account }) => account === address);

if (vote?.aye) {
if (!vote) {
return null;
}

if (vote.aye) {
return 'yes';
}

if (!vote?.aye && (vote?.isSplit || vote?.isSplitAbstain)) {
if (!vote.aye && (vote.isSplit || vote.isSplitAbstain)) {
return 'Abstain';
}

Expand Down Expand Up @@ -488,7 +492,7 @@ export async function getReferendumCommentsSS (chainName: string, refId: string
updated_at: updatedAt,
user_id: author.cid,
username: '',
votes: [{ decision: voteInformation(proposer) }]
votes: voteInformation(proposer) ? [{ decision: voteInformation(proposer) }] : []
} as unknown as CommentType));

return formattedComments;
Expand Down

0 comments on commit fa70422

Please sign in to comment.