mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-10-22 11:22:43 +02: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)
|
this.onSubmit = this.onSubmit.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmSendEther.prototype.componentWillMount = function () {
|
ConfirmSendEther.prototype.updateComponentSendErrors = function (prevProps) {
|
||||||
const { updateSendErrors } = this.props
|
const {
|
||||||
|
balance: oldBalance,
|
||||||
|
conversionRate: oldConversionRate,
|
||||||
|
} = prevProps
|
||||||
|
const {
|
||||||
|
updateSendErrors,
|
||||||
|
balance,
|
||||||
|
conversionRate,
|
||||||
|
} = this.props
|
||||||
const txMeta = this.gatherTxMeta()
|
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({
|
updateSendErrors({
|
||||||
insufficientFunds: balanceIsSufficient
|
insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'),
|
||||||
? false
|
|
||||||
: this.context.t('insufficientFunds'),
|
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfirmSendEther.prototype.componentWillMount = function () {
|
||||||
|
this.updateComponentSendErrors({})
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfirmSendEther.prototype.componentDidUpdate = function (prevProps) {
|
||||||
|
this.updateComponentSendErrors(prevProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmSendEther.prototype.getAmount = function () {
|
ConfirmSendEther.prototype.getAmount = function () {
|
||||||
|
@ -147,21 +147,43 @@ function ConfirmSendToken () {
|
|||||||
this.onSubmit = this.onSubmit.bind(this)
|
this.onSubmit = this.onSubmit.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmSendToken.prototype.componentWillMount = function () {
|
ConfirmSendToken.prototype.updateComponentSendErrors = function (prevProps) {
|
||||||
const { tokenContract, selectedAddress, updateSendErrors} = this.props
|
const {
|
||||||
|
balance: oldBalance,
|
||||||
|
conversionRate: oldConversionRate,
|
||||||
|
} = prevProps
|
||||||
|
const {
|
||||||
|
updateSendErrors,
|
||||||
|
balance,
|
||||||
|
conversionRate,
|
||||||
|
} = this.props
|
||||||
const txMeta = this.gatherTxMeta()
|
const txMeta = this.gatherTxMeta()
|
||||||
|
|
||||||
|
const shouldUpdateBalanceSendErrors = balance && [
|
||||||
|
balance !== oldBalance,
|
||||||
|
conversionRate !== oldConversionRate,
|
||||||
|
].some(x => Boolean(x))
|
||||||
|
|
||||||
|
if (shouldUpdateBalanceSendErrors) {
|
||||||
const balanceIsSufficient = this.isBalanceSufficient(txMeta)
|
const balanceIsSufficient = this.isBalanceSufficient(txMeta)
|
||||||
|
updateSendErrors({
|
||||||
|
insufficientFunds: balanceIsSufficient ? false : this.context.t('insufficientFunds'),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfirmSendToken.prototype.componentWillMount = function () {
|
||||||
|
const { tokenContract, selectedAddress } = this.props
|
||||||
tokenContract && tokenContract
|
tokenContract && tokenContract
|
||||||
.balanceOf(selectedAddress)
|
.balanceOf(selectedAddress)
|
||||||
.then(usersToken => {
|
.then(usersToken => {
|
||||||
})
|
})
|
||||||
this.props.updateTokenExchangeRate()
|
this.props.updateTokenExchangeRate()
|
||||||
|
this.updateComponentSendErrors({})
|
||||||
|
}
|
||||||
|
|
||||||
updateSendErrors({
|
ConfirmSendToken.prototype.componentDidUpdate = function (prevProps) {
|
||||||
insufficientFunds: balanceIsSufficient
|
this.updateComponentSendErrors(prevProps)
|
||||||
? false
|
|
||||||
: this.context.t('insufficientFunds'),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmSendToken.prototype.getAmount = function () {
|
ConfirmSendToken.prototype.getAmount = function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user