diff options
moved the props initialization steps into mapStateToProps
-rw-r--r-- | ui/app/components/tx-list.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/ui/app/components/tx-list.js b/ui/app/components/tx-list.js index 8f6f09348..8fa712b4a 100644 --- a/ui/app/components/tx-list.js +++ b/ui/app/components/tx-list.js @@ -7,12 +7,18 @@ const valuesFor = require('../util').valuesFor module.exports = connect(mapStateToProps)(TxList) -function mapStateToProps(state) { +function mapStateToProps (state) { + const network = state.metamask.network + const unapprovedMsgs = valuesFor(state.metamask.unapprovedMsgs) + + const shapeShiftTxList = (network === '1') ? state.metamask.shapeShiftTxList : undefined + const transactions = state.metamask.selectedAddressTxList || [] + + const txsToRender = !shapeShiftTxList ? transactions.concat(unapprovedMsgs) : transactions.concat(unapprovedMsgs, shapeShiftTxList) + .sort((a, b) => b.time - a.time) + return { - network: state.metamask.network, - unapprovedMsgs: valuesFor(state.metamask.unapprovedMsgs), - shapeShiftTxList: state.metamask.shapeShiftTxList, - transactions: state.metamask.selectedAddressTxList || [], + txsToRender, conversionRate: state.metamask.conversionRate, } } @@ -33,16 +39,9 @@ const contentDivider = h('div', { TxList.prototype.render = function () { - const { transactions, network, unapprovedMsgs, conversionRate } = this.props - - var shapeShiftTxList - if (network === '1') { - shapeShiftTxList = this.props.shapeShiftTxList - } - const txsToRender = !shapeShiftTxList ? transactions.concat(unapprovedMsgs) : transactions.concat(unapprovedMsgs, shapeShiftTxList) - .sort((a, b) => b.time - a.time) + const { txsToRender, conversionRate } = this.props - console.log("transactions to render", txsToRender) + console.log('transactions to render', txsToRender) return h('div.flex-column.tx-list-container', {}, [ |