Skip to content

Commit

Permalink
Sorting News by Date (cryptonomex#881)
Browse files Browse the repository at this point in the history
* modifiying table padding and borders

* test

* adding sorting by date

* fixing to merge

* fixing to merge
  • Loading branch information
maiopirata authored and svk31 committed Dec 18, 2017
1 parent ae46d0d commit f960498
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ app/bundle
app/stats-dev.json
app/stats-prod.json
app/test/MarketClasses.js
.yarn.lock
yarn.lock
9 changes: 8 additions & 1 deletion app/components/News.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,25 @@ class News extends React.Component {
width: 1200
};
this.updateDimensions = this.updateDimensions.bind(this);
this.orderDiscussions = this.orderDiscussions.bind(this);
}

updateDimensions() {
this.setState({ width: window.innerWidth });
}

orderDiscussions(discussions) {
const orderedDiscussions = discussions
.sort((a, b) => (new Date(b.active) - new Date(a.active)))
this.setState({discussions: orderedDiscussions, isLoading: false})
}

componentDidMount() {
this.updateDimensions();
window.addEventListener("resize", this.updateDimensions);
steem.api.getDiscussionsByBlog(query, (err, discussions) => {
if (err) this.setState({isLoading: false, isWrong: true})
this.setState({discussions, isLoading: false})
this.orderDiscussions(discussions)
});
}

Expand Down

0 comments on commit f960498

Please sign in to comment.