1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 20:39:08 +01:00

Clean up code

This commit is contained in:
Frankie 2017-01-13 10:44:22 -08:00
parent 34081c8cb2
commit 5ed52eed68
4 changed files with 39 additions and 34 deletions

View File

@ -25,8 +25,9 @@ module.exports = class TransactionManager extends EventEmitter {
getState () { getState () {
var selectedAccount = this.getSelectedAccount() var selectedAccount = this.getSelectedAccount()
return { return {
transactions: this.getTxList(),
unconfTxs: this.getUnapprovedTxList(), unconfTxs: this.getUnapprovedTxList(),
transactions: this.getFilteredTxList({metamaskNetworkId: this.getNetwork(), from: selectedAccount}), selectedAccountTxList: this.getFilteredTxList({metamaskNetworkId: this.getNetwork(), from: selectedAccount}),
} }
} }

View File

@ -29,7 +29,7 @@ function mapStateToProps (state) {
network: state.metamask.network, network: state.metamask.network,
unconfMsgs: valuesFor(state.metamask.unconfMsgs), unconfMsgs: valuesFor(state.metamask.unconfMsgs),
shapeShiftTxList: state.metamask.shapeShiftTxList, shapeShiftTxList: state.metamask.shapeShiftTxList,
transactions: state.metamask.transactions, transactions: state.metamask.selectedAccountTxList || [],
} }
} }
@ -249,9 +249,8 @@ AccountDetailScreen.prototype.subview = function () {
AccountDetailScreen.prototype.transactionList = function () { AccountDetailScreen.prototype.transactionList = function () {
const {transactions, unconfMsgs, address, network, shapeShiftTxList } = this.props const {transactions, unconfMsgs, address, network, shapeShiftTxList } = this.props
// sort by recency // sort by recency
var soretedTxs = transactions.sort((a, b) => b.time - a.time)
return h(TransactionList, { return h(TransactionList, {
transactions: soretedTxs, transactions: transactions.sort((a, b) => b.time - a.time),
network, network,
unconfMsgs, unconfMsgs,
address, address,

View File

@ -13,37 +13,42 @@ function TransactionIcon () {
TransactionIcon.prototype.render = function () { TransactionIcon.prototype.render = function () {
const { transaction, txParams, isMsg } = this.props const { transaction, txParams, isMsg } = this.props
if (transaction.status === 'unapproved') { switch (transaction.status) {
case 'unapproved':
return h('.unapproved-tx', { return h('.unapproved-tx', {
style: { style: {
width: '15px', width: '24px',
height: '15px', height: '24px',
background: '#00bfff', background: '#4dffff',
border: 'solid',
borderColor: '#AEAEAE',
borderWidth: '0.5px',
borderRadius: '13px', borderRadius: '13px',
}, },
}) })
} else if (transaction.status === 'rejected') { case 'rejected':
return h('i.fa.fa-exclamation-triangle.fa-lg.warning', { return h('i.fa.fa-exclamation-triangle.fa-lg.warning', {
style: { style: {
width: '24px', width: '24px',
}, },
}) })
} else if (transaction.status === 'signed') {
case 'failed':
return h('i.fa.fa-exclamation-triangle.fa-lg.error', {
style: {
width: '24px',
},
})
case 'signed':
return h('i.fa.fa-ellipsis-h', { return h('i.fa.fa-ellipsis-h', {
style: { style: {
fontSize: '27px', fontSize: '27px',
}, },
}) })
} else if (transaction.status === 'failed') {
return h('i.fa.fa-exclamation-triangle.fa-lg.warning', {
style: {
fontSize: '24px',
},
})
} }
if (isMsg) { if (isMsg) {
return h('i.fa.fa-certificate.fa-lg', { return h('i.fa.fa-certificate.fa-lg', {
style: { style: {

View File

@ -13,13 +13,13 @@ function TransactionList () {
} }
TransactionList.prototype.render = function () { TransactionList.prototype.render = function () {
const { transactions = [], network, unconfMsgs } = this.props const { transactions, network, unconfMsgs } = this.props
var shapeShiftTxList var shapeShiftTxList
if (network === '1') { if (network === '1') {
shapeShiftTxList = this.props.shapeShiftTxList shapeShiftTxList = this.props.shapeShiftTxList
} }
const txsToRender = !shapeShiftTxList ? transactions.concat(unconfMsgs) : txsToRender.concat(unconfMsgs, shapeShiftTxList) const txsToRender = !shapeShiftTxList ? transactions.concat(unconfMsgs) : transactions.concat(unconfMsgs, shapeShiftTxList)
.sort((a, b) => b.time - a.time) .sort((a, b) => b.time - a.time)
return ( return (