From d99aa3192c41b778f38d5734de61b24683385b12 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Tue, 28 Mar 2017 08:35:10 +0200 Subject: [PATCH] Fix default list sorting (#5303) * Fix default sorting for lists views * Linting --- js/src/ui/Actionbar/Sort/sortStore.js | 4 +++- js/src/views/Contracts/contracts.js | 14 ++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/js/src/ui/Actionbar/Sort/sortStore.js b/js/src/ui/Actionbar/Sort/sortStore.js index 0d32b2b06..ae02a34cb 100644 --- a/js/src/ui/Actionbar/Sort/sortStore.js +++ b/js/src/ui/Actionbar/Sort/sortStore.js @@ -47,7 +47,9 @@ export default class SortStore { @action restoreSavedOrder = () => { const order = this.getSavedOrder(); - this.onChange(order); + if (order) { + this.onChange(order); + } } getSavedOrder = () => { diff --git a/js/src/views/Contracts/contracts.js b/js/src/views/Contracts/contracts.js index 938fc12b5..33b475c5f 100644 --- a/js/src/views/Contracts/contracts.js +++ b/js/src/views/Contracts/contracts.js @@ -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 ( ); } @@ -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));