From 87cb930130cb43130bf584552451aad4795dd210 Mon Sep 17 00:00:00 2001 From: Simon Liang Date: Thu, 10 Aug 2017 11:06:37 +0800 Subject: moved the props initialization steps into mapStateToProps --- ui/app/components/tx-list.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'ui/app/components') 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', {}, [ -- cgit v1.2.3