mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 20:02:58 +01:00
UpdateSendErrors only called when balance defined, recalled if balance updates.
This commit is contained in:
parent
a180fb0320
commit
1dc3c51b54
@ -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 () {
|
||||
|
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user