Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Fix search and remove unnecessary setStates
Browse files Browse the repository at this point in the history
  • Loading branch information
reyraa committed Sep 17, 2017
1 parent 287594f commit 4c66e04
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/components/voting/voting.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ const Table = themr(TABLE, TableTheme)(tableFactory(TableHead, VotingRow));
class Voting extends React.Component {
constructor() {
super();
this.state = {
delegates: [],
selected: [],
length: 1,
notFound: '',
};
this.freezeLoading = false;
this.isInitial = true;
this.offset = -1;
this.query = '';
}
Expand All @@ -35,6 +30,7 @@ class Voting extends React.Component {
setTimeout(() => {
this.freezeLoading = false;
this.offset = nextProps.delegates.length;
this.isInitial = false;
}, 5);
}
}
Expand All @@ -60,14 +56,10 @@ class Voting extends React.Component {
*/
search(query) {
this.query = query;
this.setState({
offset: 0,
delegates: [],
length: 1,
});
this.offset = 0;
this.freezeLoading = false;
setTimeout(() => {
this.loadDelegates(this.query);
this.loadDelegates(this.query, true);
}, 1);
}

Expand Down Expand Up @@ -101,7 +93,6 @@ class Voting extends React.Component {
}

render() {
// .log(this.props.votes.cc001);
return (
<div className="box noPaddingBox">
<Header
Expand Down Expand Up @@ -129,10 +120,13 @@ class Voting extends React.Component {
))}
</Table>
</div>
{this.state.notFound}
{
(!this.isInitial && this.props.delegates.length === 0) &&
<div className='hasPaddingRow empty-message'>No delegates found</div>
}
<Waypoint bottomOffset='-80%'
scrollableAncestor={window}
key={this.state.delegates.length}
key={this.props.delegates.length}
onEnter={this.loadMore.bind(this)}></Waypoint>
</div>
);
Expand Down

0 comments on commit 4c66e04

Please sign in to comment.