1
0
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:
Dan 2018-04-02 16:26:19 -02:30
parent a180fb0320
commit 1dc3c51b54
3 changed files with 291 additions and 343 deletions

View File

@ -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 () {

View File

@ -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 () {

559
yarn.lock

File diff suppressed because it is too large Load Diff