aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-11-10 11:49:16 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-11-15 08:18:00 +0800
commit9e3f921ba928a948c04b4156daa0a3f752ee2dde (patch)
tree61879e2bdcf2250e1c8ee7798e78df001f2ca3f0 /ui
parent4671f28476165fec43785ae23352c1e9a0776abc (diff)
downloadtangerine-wallet-browser-9e3f921ba928a948c04b4156daa0a3f752ee2dde.tar.gz
tangerine-wallet-browser-9e3f921ba928a948c04b4156daa0a3f752ee2dde.tar.zst
tangerine-wallet-browser-9e3f921ba928a948c04b4156daa0a3f752ee2dde.zip
Create single action for updating all of send in redux state.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/actions.js9
-rw-r--r--ui/app/components/pending-tx/confirm-send-ether.js15
-rw-r--r--ui/app/components/pending-tx/confirm-send-token.js15
-rw-r--r--ui/app/components/send/currency-display.js2
-rw-r--r--ui/app/reducers/metamask.js10
5 files changed, 38 insertions, 13 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 0d7f03d0e..2ca62c41f 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -149,6 +149,7 @@ var actions = {
UPDATE_SEND_AMOUNT: 'UPDATE_SEND_AMOUNT',
UPDATE_SEND_MEMO: 'UPDATE_SEND_MEMO',
UPDATE_SEND_ERRORS: 'UPDATE_SEND_ERRORS',
+ UPDATE_SEND: 'UPDATE_SEND',
CLEAR_SEND: 'CLEAR_SEND',
updateGasLimit,
updateGasPrice,
@@ -159,6 +160,7 @@ var actions = {
updateSendAmount,
updateSendMemo,
updateSendErrors,
+ updateSend,
clearSend,
setSelectedAddress,
// app messages
@@ -632,6 +634,13 @@ function updateSendErrors (error) {
}
}
+function updateSend (newSend) {
+ return {
+ type: actions.UPDATE_SEND,
+ value: newSend,
+ }
+}
+
function clearSend () {
return {
type: actions.CLEAR_SEND,
diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js
index b4d955b80..1264da153 100644
--- a/ui/app/components/pending-tx/confirm-send-ether.js
+++ b/ui/app/components/pending-tx/confirm-send-ether.js
@@ -43,12 +43,15 @@ function mapDispatchToProps (dispatch) {
to,
value: amount,
} = txParams
- dispatch(actions.editTx(id))
- dispatch(actions.updateGasLimit(gasLimit))
- dispatch(actions.updateGasPrice(gasPrice))
- dispatch(actions.updateSendTo(to))
- dispatch(actions.updateSendAmount(amount))
- dispatch(actions.updateSendErrors({ to: null, amount: null }))
+ dispatch(actions.updateSend({
+ gasLimit,
+ gasPrice,
+ gasTotal: null,
+ to,
+ amount,
+ errors: { to: null, amount: null },
+ editingTransactionId: id,
+ }))
dispatch(actions.showSendPage())
},
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js
index aab45f2a4..cc2df8299 100644
--- a/ui/app/components/pending-tx/confirm-send-token.js
+++ b/ui/app/components/pending-tx/confirm-send-token.js
@@ -77,13 +77,16 @@ function mapDispatchToProps (dispatch, ownProps) {
gasPrice,
to,
} = txParams
- dispatch(actions.editTx(id))
- dispatch(actions.updateGasLimit(gasLimit))
- dispatch(actions.updateGasPrice(gasPrice))
- dispatch(actions.updateSendTo(to))
- dispatch(actions.updateSendAmount(amount))
- dispatch(actions.updateSendErrors({ to: null, amount: null }))
dispatch(actions.setSelectedToken(address))
+ dispatch(actions.updateSend({
+ gasLimit,
+ gasPrice,
+ gasTotal: null,
+ to,
+ amount,
+ errors: { to: null, amount: null },
+ editingTransactionId: id,
+ }))
dispatch(actions.showSendTokenPage())
},
}
diff --git a/ui/app/components/send/currency-display.js b/ui/app/components/send/currency-display.js
index 5bf8d6aa0..819fee0a0 100644
--- a/ui/app/components/send/currency-display.js
+++ b/ui/app/components/send/currency-display.js
@@ -97,7 +97,7 @@ CurrencyDisplay.prototype.render = function () {
onInputChange: newValue => {
handleChange(this.getAmount(newValue))
},
- inputRef: input => { this.currencyInput = input; },
+ inputRef: input => { this.currencyInput = input },
}),
h('span.currency-display__currency-symbol', primaryCurrency),
diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js
index 56bf1fba6..83161320e 100644
--- a/ui/app/reducers/metamask.js
+++ b/ui/app/reducers/metamask.js
@@ -257,17 +257,27 @@ function reduceMetamask (state, action) {
},
})
+ case actions.UPDATE_SEND:
+ return extend(metamaskState, {
+ send: {
+ ...metamaskState.send,
+ ...action.value,
+ },
+ })
+
case actions.CLEAR_SEND:
return extend(metamaskState, {
send: {
gasLimit: null,
gasPrice: null,
gasTotal: null,
+ tokenBalance: null,
from: '',
to: '',
amount: '0x0',
memo: '',
errors: {},
+ editingTransactionId: null,
},
})