Skip to content

Commit

Permalink
Fix voted field loading (#1086)
Browse files Browse the repository at this point in the history
* fix: proposal result voted field loading

* Improve nil check
  • Loading branch information
hyifeng authored Feb 18, 2025
1 parent 43ece7f commit 135f544
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions next/components/postDetail/postResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import isNil from "lodash.isnil";
import LoadingField from "../loadingField";

export function InnerPostResult({ data, voteStatus, space }) {
const votedAmount = data?.votedWeights?.balanceOf;
const societyVotedAmount = data?.votedWeights?.societyVote;
const votedAmount = data?.votedWeights?.balanceOf || 0;
const societyVotedAmount = data?.votedWeights?.societyVote || 0;

const results = data?.weightStrategy?.map((strategy) => {
if (strategy === "balance-of") {
Expand Down Expand Up @@ -99,7 +99,7 @@ export function InnerPostResult({ data, voteStatus, space }) {
<VoteItem>
<div>Voted</div>
<div>
<LoadingField isLoading={isNil(votedAmount)}>
<LoadingField isLoading={isNil(data)}>
<ValueDisplay value={votedAmount?.toString()} space={space} />
</LoadingField>
</div>
Expand All @@ -110,7 +110,7 @@ export function InnerPostResult({ data, voteStatus, space }) {
<VoteItem>
<div>Voted</div>
<div>
<LoadingField isLoading={isNil(societyVotedAmount)}>
<LoadingField isLoading={isNil(data)}>
{societyVotedAmount} VOTE
</LoadingField>
</div>
Expand All @@ -127,7 +127,7 @@ export function InnerPostResult({ data, voteStatus, space }) {
<VoteItem>
<div>Voters</div>
<div>
<LoadingField isLoading={isNil(data?.votesCount)}>
<LoadingField isLoading={isNil(data)}>
{data?.votesCount}
</LoadingField>
</div>
Expand Down

0 comments on commit 135f544

Please sign in to comment.