Skip to content

Commit

Permalink
feat: switch to Vote phase in real time
Browse files Browse the repository at this point in the history
  • Loading branch information
liorfrenkel committed Apr 8, 2020
1 parent bc4099d commit c8156ad
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/pages/cgp/CGP.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,20 @@ class CGPPage extends React.Component {
// autorun was reacting to unknown properties, use reaction instead
this.forceDisposer = reaction(
() => this.props.rootStore.blockStore.blocksCount,
() => this.loadRelevantInterval()
() => {
if (this.relevantLoaded) {
const { snapshot, tally, phase } = this.cgpStore.relevantInterval;
//
if (phase === 'Nomination' && this.currentBlock == snapshot + (tally - snapshot) / 2) { // eslint-disable-line eqeqeq
// nomination is switched to vote RIGHT NOW
this.props.history.push({
pathname: getPageUrl({ interval: this.intervalRouteParam, phase: 'Vote' }),
});
} else {
this.loadRelevantInterval({ phase });
}
}
}
);
}
stopReload() {
Expand Down Expand Up @@ -156,9 +169,7 @@ class CGPPage extends React.Component {

<div className="row mb-3">
<div className="col-md-8">
<h4>
{getPhaseName(cgpStore.relevantInterval.phase)} phase
</h4>
<h4>{getPhaseName(cgpStore.relevantInterval.phase)} phase</h4>
</div>
<div className="col-md-4">
<IntervalsDropDown
Expand Down

0 comments on commit c8156ad

Please sign in to comment.