From 279c339ab54a3dcdd38ebbcca15b33b75de4ebfb Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 5 Sep 2017 22:25:33 +0300 Subject: [PATCH] walletsData comp receive props refactor --- .../dashboard/walletsData/walletsData.js | 37 ++++++++++--------- .../walletsData/walletsData.render.js | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/react/src/components/dashboard/walletsData/walletsData.js b/react/src/components/dashboard/walletsData/walletsData.js index a317b2b..754cae6 100644 --- a/react/src/components/dashboard/walletsData/walletsData.js +++ b/react/src/components/dashboard/walletsData/walletsData.js @@ -324,44 +324,46 @@ class WalletsData extends React.Component { } componentWillReceiveProps(props) { + let _stateChange = {}; + if (!this.state.currentAddress && this.props.ActiveCoin.activeAddress && this.props.ActiveCoin.mode === 'basilisk') { - this.setState(Object.assign({}, this.state, { + _stateChange = Object.assign({}, this.state, { currentAddress: this.props.ActiveCoin.activeAddress, - })); + }); } + // TODO: clean if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory !== 'loading' && this.props.ActiveCoin.txhistory !== 'no data' && this.props.ActiveCoin.txhistory.length) { - if (!this.state.itemsList || + /*if (!this.state.itemsList || this.state.itemsList === 'no data' || (this.state.coin && this.state.coin !== this.props.ActiveCoin.coin) || - (JSON.stringify(this.props.ActiveCoin.txhistory) !== JSON.stringify(this.state.txhistory))) { - this.setState(Object.assign({}, this.state, { + (JSON.stringify(this.props.ActiveCoin.txhistory) !== JSON.stringify(this.state.txhistory))) {*/ + _stateChange = Object.assign({}, this.state, { itemsList: this.props.ActiveCoin.txhistory, filteredItemsList: this.filterTransactions(this.props.ActiveCoin.txhistory, this.state.searchTerm), txhistory: this.props.ActiveCoin.txhistory, showPagination: this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory.length >= this.state.defaultPageSize, - })); - } + itemsListColumns: this.generateItemsListColumns(), + }); + //} } if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory === 'no data') { - this.setState(Object.assign({}, this.state, { - itemsList: 'no data', - })); + _stateChange = Object.assign({}, this.state, { + itemsList: 'no data', + }); } else if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory === 'loading') { - this.setState(Object.assign({}, this.state, { + _stateChange = Object.assign({}, this.state, { itemsList: 'loading', - })); + }); } - this.setState({ - itemsListColumns: this.generateItemsListColumns(), - }); + this.setState(Object.assign({}, this.state, _stateChange)); } isFullySynced() { @@ -380,8 +382,7 @@ class WalletsData extends React.Component { // TODO: add basilisk first run check, display no data if second run renderTxHistoryList() { - if (this.state.itemsList === 'loading' || - this.state.itemsList.length == 0) { + if (this.state.itemsList === 'loading') { if (this.isFullySynced()) { return ( @@ -401,7 +402,7 @@ class WalletsData extends React.Component { { translate('INDEX.NO_DATA') } ); - } else if (this.state.itemsList) { + } else if (this.state.itemsList && this.state.itemsList.length) { return TxHistoryListRender.call(this); } diff --git a/react/src/components/dashboard/walletsData/walletsData.render.js b/react/src/components/dashboard/walletsData/walletsData.render.js index 3e50ece..6aa4c8e 100644 --- a/react/src/components/dashboard/walletsData/walletsData.render.js +++ b/react/src/components/dashboard/walletsData/walletsData.render.js @@ -256,7 +256,7 @@ export const WalletsDataRender = function() { { this.renderAddressList() } } - { this.props.ActiveCoin.txhistory !== 'loading' && + { (this.props.ActiveCoin.txhistory !== 'loading' && this.props.ActiveCoin.txhistory !== 'no data') &&