Skip to content

Commit

Permalink
Merge pull request #680 from eco-stake/handle-proposals-without-content
Browse files Browse the repository at this point in the history
Handle proposals with no content
  • Loading branch information
tombeynon authored Nov 25, 2022
2 parents 041a959 + fdfff66 commit 61a48ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Proposals.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Proposals(props) {
<td className="d-none d-md-table-cell">{proposalId}</td>
<td>
<span role="button" onClick={() => props.showProposal(proposal)}>
{proposal.content.title}
{proposal.title}
</span>
</td>
<td className="d-none d-sm-table-cell text-center text-nowrap">
Expand Down
9 changes: 5 additions & 4 deletions src/utils/Proposal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ export const PROPOSAL_STATUSES = {

const Proposal = (data) => {

const { title, description } = data.content
const type = data.content['@type']
const { title, description } = data.content || {}
const type = data.content && data.content['@type']

const fixedDescription = description.split(/\\n/).join('\n')
const fixedDescription = description && description.split(/\\n/).join('\n')
const statusHuman = PROPOSAL_STATUSES[data.status]
const typeHuman = type.split('.').reverse()[0]
const typeHuman = type ? type.split('.').reverse()[0] : 'Unknown'

const isDeposit = data.status === 'PROPOSAL_STATUS_DEPOSIT_PERIOD'
const isVoting = data.status === 'PROPOSAL_STATUS_VOTING_PERIOD'

return {
...data,
title,
type,
fixedDescription,
statusHuman,
Expand Down

0 comments on commit 61a48ed

Please sign in to comment.