Skip to content

Commit

Permalink
automatically refresh voting status (#2102)
Browse files Browse the repository at this point in the history
  • Loading branch information
roienatan authored and Oren Sokolowsky committed Sep 7, 2020
1 parent 2823dd5 commit 973cd43
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/components/Proposal/ProposalDetailsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, IDAOState, IProposalStage, IContributionRewardExtState } from "@daostack/arc.js";
import { Address, IDAOState, IProposalStage, IContributionRewardExtState, IProposalOutcome } from "@daostack/arc.js";
import classNames from "classnames";
import AccountPopup from "components/Account/AccountPopup";
import AccountProfileName from "components/Account/AccountProfileName";
Expand Down Expand Up @@ -123,6 +123,7 @@ class ProposalDetailsPage extends React.Component<IProps, IState> {
proposal,
rewards,
stakes,
votes,
} = this.props;

const proposalState = proposal.coreState;
Expand All @@ -139,6 +140,13 @@ class ProposalDetailsPage extends React.Component<IProps, IState> {
this.disqusConfig.url = process.env.BASE_URL + this.props.location.pathname;
this.disqusConfig.identifier = this.props.proposalId;

let currentAccountVote: IProposalOutcome | undefined;

if (votes.length > 0) {
const currentVote = this.props.votes[0];
currentAccountVote = currentVote.coreState.outcome;
}

return (
<div className={css.wrapper}>
<BreadcrumbsItem weight={1} to={`/dao/${daoState.address}/plugin/${proposalState.plugin.id}`}>{pluginName(proposalState.plugin.entity.coreState, proposalState.plugin.entity.coreState.address)}</BreadcrumbsItem>
Expand Down Expand Up @@ -225,7 +233,7 @@ class ProposalDetailsPage extends React.Component<IProps, IState> {
<VoteButtons
altStyle
currentAccountAddress={currentAccountAddress}
currentVote={this.state.currentAccountVote}
currentVote={currentAccountVote}
daoState={daoState}
expired={expired}
currentAccountState={member}
Expand Down Expand Up @@ -256,7 +264,7 @@ class ProposalDetailsPage extends React.Component<IProps, IState> {
<VoteButtons
currentAccountAddress={currentAccountAddress}
currentAccountState={member}
currentVote={this.state.currentAccountVote}
currentVote={currentAccountVote}
daoState={daoState}
expired={expired}
proposalState={proposalState}
Expand All @@ -273,7 +281,7 @@ class ProposalDetailsPage extends React.Component<IProps, IState> {
<VoteBreakdown
currentAccountAddress={currentAccountAddress}
currentAccountState={member}
currentVote={this.state.currentAccountVote}
currentVote={currentAccountVote}
daoState={daoState}
detailView
proposalState={proposalState} />
Expand Down

0 comments on commit 973cd43

Please sign in to comment.