Browse Source

walletsData comp receive props refactor

all-modes
pbca26 8 years ago
parent
commit
279c339ab5
  1. 35
      react/src/components/dashboard/walletsData/walletsData.js
  2. 2
      react/src/components/dashboard/walletsData/walletsData.render.js

35
react/src/components/dashboard/walletsData/walletsData.js

@ -324,44 +324,46 @@ class WalletsData extends React.Component {
} }
componentWillReceiveProps(props) { componentWillReceiveProps(props) {
let _stateChange = {};
if (!this.state.currentAddress && if (!this.state.currentAddress &&
this.props.ActiveCoin.activeAddress && this.props.ActiveCoin.activeAddress &&
this.props.ActiveCoin.mode === 'basilisk') { this.props.ActiveCoin.mode === 'basilisk') {
this.setState(Object.assign({}, this.state, { _stateChange = Object.assign({}, this.state, {
currentAddress: this.props.ActiveCoin.activeAddress, currentAddress: this.props.ActiveCoin.activeAddress,
})); });
} }
// TODO: clean
if (this.props.ActiveCoin.txhistory && if (this.props.ActiveCoin.txhistory &&
this.props.ActiveCoin.txhistory !== 'loading' && this.props.ActiveCoin.txhistory !== 'loading' &&
this.props.ActiveCoin.txhistory !== 'no data' && this.props.ActiveCoin.txhistory !== 'no data' &&
this.props.ActiveCoin.txhistory.length) { 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) || (this.state.coin && this.state.coin !== this.props.ActiveCoin.coin) ||
(JSON.stringify(this.props.ActiveCoin.txhistory) !== JSON.stringify(this.state.txhistory))) { (JSON.stringify(this.props.ActiveCoin.txhistory) !== JSON.stringify(this.state.txhistory))) {*/
this.setState(Object.assign({}, this.state, { _stateChange = Object.assign({}, this.state, {
itemsList: this.props.ActiveCoin.txhistory, itemsList: this.props.ActiveCoin.txhistory,
filteredItemsList: this.filterTransactions(this.props.ActiveCoin.txhistory, this.state.searchTerm), filteredItemsList: this.filterTransactions(this.props.ActiveCoin.txhistory, this.state.searchTerm),
txhistory: this.props.ActiveCoin.txhistory, txhistory: this.props.ActiveCoin.txhistory,
showPagination: this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory.length >= this.state.defaultPageSize, showPagination: this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory.length >= this.state.defaultPageSize,
})); itemsListColumns: this.generateItemsListColumns(),
} });
//}
} }
if (this.props.ActiveCoin.txhistory && if (this.props.ActiveCoin.txhistory &&
this.props.ActiveCoin.txhistory === 'no data') { this.props.ActiveCoin.txhistory === 'no data') {
this.setState(Object.assign({}, this.state, { _stateChange = Object.assign({}, this.state, {
itemsList: 'no data', itemsList: 'no data',
})); });
} else if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory === 'loading') { } else if (this.props.ActiveCoin.txhistory && this.props.ActiveCoin.txhistory === 'loading') {
this.setState(Object.assign({}, this.state, { _stateChange = Object.assign({}, this.state, {
itemsList: 'loading', itemsList: 'loading',
})); });
} }
this.setState({ this.setState(Object.assign({}, this.state, _stateChange));
itemsListColumns: this.generateItemsListColumns(),
});
} }
isFullySynced() { isFullySynced() {
@ -380,8 +382,7 @@ class WalletsData extends React.Component {
// TODO: add basilisk first run check, display no data if second run // TODO: add basilisk first run check, display no data if second run
renderTxHistoryList() { renderTxHistoryList() {
if (this.state.itemsList === 'loading' || if (this.state.itemsList === 'loading') {
this.state.itemsList.length == 0) {
if (this.isFullySynced()) { if (this.isFullySynced()) {
return ( return (
<tr className="hover--none"> <tr className="hover--none">
@ -401,7 +402,7 @@ class WalletsData extends React.Component {
<td colSpan="7" className="table-cell-offset-16">{ translate('INDEX.NO_DATA') }</td> <td colSpan="7" className="table-cell-offset-16">{ translate('INDEX.NO_DATA') }</td>
</tr> </tr>
); );
} else if (this.state.itemsList) { } else if (this.state.itemsList && this.state.itemsList.length) {
return TxHistoryListRender.call(this); return TxHistoryListRender.call(this);
} }

2
react/src/components/dashboard/walletsData/walletsData.render.js

@ -256,7 +256,7 @@ export const WalletsDataRender = function() {
{ this.renderAddressList() } { this.renderAddressList() }
</div> </div>
} }
{ this.props.ActiveCoin.txhistory !== 'loading' && { (this.props.ActiveCoin.txhistory !== 'loading' && this.props.ActiveCoin.txhistory !== 'no data') &&
<div className="col-sm-4 search-box"> <div className="col-sm-4 search-box">
<input <input
className="form-control" className="form-control"

Loading…
Cancel
Save