Skip to content

fix: proposal #1 votes not displaying due to missing vote_counts#221

Open
hopkdj wants to merge 1 commit into
effectai:mainfrom
hopkdj:fix/proposal-1-votes-not-displaying
Open

fix: proposal #1 votes not displaying due to missing vote_counts#221
hopkdj wants to merge 1 commit into
effectai:mainfrom
hopkdj:fix/proposal-1-votes-not-displaying

Conversation

@hopkdj
Copy link
Copy Markdown

@hopkdj hopkdj commented Apr 1, 2026

Problem

The first proposal (#1) does not show votes even though they exist on the blockchain. This is caused by vote_counts being undefined or having a different structure for older proposals, which causes a JavaScript error when rendering the votes section.

Root Cause

Two places access vote_counts without null safety:

  1. votePercentage() in pages/proposals/_id/index.vue - directly accesses proposal.vote_counts[0].value which throws when undefined
  2. Proposals.vue - accesses proposal.vote_counts[1] without checking if array exists

Fix

  • Added defensive checks in votePercentage() to return 0.00 when vote_counts is missing
  • Added array existence check in Proposals.vue before accessing indices

Fixes #184

- Add defensive null/undefined checks in votePercentage() function
  to handle proposals where vote_counts array is missing or malformed
- Add safety checks in Proposals.vue before accessing vote_counts[1]
  and vote_counts[2]

Fixes effectai#184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First proposal doesn't show votes

1 participant