aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-04-03 02:56:19 +0800
committerDan <danjm.com@gmail.com>2018-04-03 02:56:19 +0800
commit1dc3c51b5445996e9111cabe863fb0eef65dcfc5 (patch)
tree1550ace04b6e59c4654bddfa18f678d41c7a9e79 /ui
parenta180fb03209bdbc4df9645a665108a8cd8788a5a (diff)
downloadtangerine-wallet-browser-1dc3c51b5445996e9111cabe863fb0eef65dcfc5.tar.gz
tangerine-wallet-browser-1dc3c51b5445996e9111cabe863fb0eef65dcfc5.tar.zst
tangerine-wallet-browser-1dc3c51b5445996e9111cabe863fb0eef65dcfc5.zip
UpdateSendErrors only called when balance defined, recalled if balance updates.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/components/pending-tx/confirm-send-ether.js37
-rw-r--r--ui/app/components/pending-tx/confirm-send-token.js38
2 files changed, 59 insertions, 16 deletions
diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js
index 2474516d4..eae70b279 100644
--- a/ui/app/components/pending-tx/confirm-send-ether.js
+++ b/ui/app/components/pending-tx/confirm-send-ether.js
@@ -109,16 +109,37 @@ function ConfirmSendEther () {
this.onSubmit = this.onSubmit.bind(this)
}
-ConfirmSendEther.prototype.componentWillMount = function () {
- const { updateSendErrors } = this.props
+ConfirmSendEther.prototype.updateComponentSendErrors = function (prevProps) {
+ const {
+ balance: oldBalance,
+ conversionRate: oldConversionRate,
+ } = prevProps
+ const {
+ updateSendErrors,
+ balance,
+ conversionRate,
+ } = this.props
const txMeta = this.gatherTxMeta()
- const balanceIsSufficient = this.isBalanceSufficient(txMeta)
- updateSendErrors({
- insufficientFunds: balanceIsSufficient
- ? false
- : this.context.t('insufficientFunds'),
- })
+ const shouldUpdateBalanceSendErrors = balance && [
+ balance !== oldBalance,
+ conversionRate !== oldConversionRate,
+ ].some(x => Boolean(x))
+
+ if (shouldUpdateBalanceSendErrors) {
+ const balanceIsSufficient = this.isBalanceSufficient(txMeta)
+ updateSendErrors({
+ insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'),
+ })
+ }
+}
+
+ConfirmSendEther.prototype.componentWillMount = function () {
+ this.updateComponentSendErrors({})
+}
+
+ConfirmSendEther.prototype.componentDidUpdate = function (prevProps) {
+ this.updateComponentSendErrors(prevProps)
}
ConfirmSendEther.prototype.getAmount = function () {
diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js
index dd9fdc23f..814386c5c 100644
--- a/ui/app/components/pending-tx/confirm-send-token.js
+++ b/ui/app/components/pending-tx/confirm-send-token.js
@@ -147,21 +147,43 @@ function ConfirmSendToken () {
this.onSubmit = this.onSubmit.bind(this)
}
-ConfirmSendToken.prototype.componentWillMount = function () {
- const { tokenContract, selectedAddress, updateSendErrors} = this.props
+ConfirmSendToken.prototype.updateComponentSendErrors = function (prevProps) {
+ const {
+ balance: oldBalance,
+ conversionRate: oldConversionRate,
+ } = prevProps
+ const {
+ updateSendErrors,
+ balance,
+ conversionRate,
+ } = this.props
const txMeta = this.gatherTxMeta()
- const balanceIsSufficient = this.isBalanceSufficient(txMeta)
+
+ const shouldUpdateBalanceSendErrors = balance && [
+ balance !== oldBalance,
+ conversionRate !== oldConversionRate,
+ ].some(x => Boolean(x))
+
+ if (shouldUpdateBalanceSendErrors) {
+ const balanceIsSufficient = this.isBalanceSufficient(txMeta)
+ updateSendErrors({
+ insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'),
+ })
+ }
+}
+
+ConfirmSendToken.prototype.componentWillMount = function () {
+ const { tokenContract, selectedAddress } = this.props
tokenContract && tokenContract
.balanceOf(selectedAddress)
.then(usersToken => {
})
this.props.updateTokenExchangeRate()
+ this.updateComponentSendErrors({})
+}
- updateSendErrors({
- insufficientFunds: balanceIsSufficient
- ? false
- : this.context.t('insufficientFunds'),
- })
+ConfirmSendToken.prototype.componentDidUpdate = function (prevProps) {
+ this.updateComponentSendErrors(prevProps)
}
ConfirmSendToken.prototype.getAmount = function () {