Fix default list sorting (#5303)

* Fix default sorting for lists views

* Linting
This commit is contained in:
Nicolas Gotchac 2017-03-28 08:35:10 +02:00 committed by Jaco Greeff
parent 8a664c524c
commit d99aa3192c
2 changed files with 11 additions and 7 deletions

View File

@ -47,7 +47,9 @@ export default class SortStore {
@action restoreSavedOrder = () => {
const order = this.getSavedOrder();
this.onChange(order);
if (order) {
this.onChange(order);
}
}
getSavedOrder = () => {

View File

@ -66,7 +66,7 @@ class Contracts extends Component {
state = {
addContract: false,
deployContract: false,
sortOrder: 'blockNumber',
sortOrder: 'blockNumber:-1',
searchValues: [],
searchTokens: []
}
@ -121,18 +121,16 @@ class Contracts extends Component {
}
renderSortButton () {
const onChange = (sortOrder) => {
this.setState({ sortOrder });
};
const { sortOrder } = this.state;
return (
<ActionbarSort
key='sortAccounts'
id='sortContracts'
order={ this.state.sortOrder }
order={ sortOrder }
metas={ META_SORT }
showDefault={ false }
onChange={ onChange }
onChange={ this.handleSortChange }
/>
);
}
@ -239,6 +237,10 @@ class Contracts extends Component {
);
}
handleSortChange = (sortOrder) => {
this.setState({ sortOrder });
}
onAddSearchToken = (token) => {
const { searchTokens } = this.state;
const newSearchTokens = uniq([].concat(searchTokens, token));