1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 07:16:36 +01:00

Fix usage of setState in ConfirmTransactionBase#handleSubmit (#5799)

This commit is contained in:
Whymarrh Whitby 2018-11-21 15:22:18 -03:30 committed by GitHub
parent 74c18ef0e8
commit 7229f0f9fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -295,22 +295,35 @@ export default class ConfirmTransactionBase extends Component {
return
}
this.setState({ submitting: true, submitError: null })
if (onSubmit) {
Promise.resolve(onSubmit(txData))
.then(this.setState({ submitting: false }))
} else {
sendTransaction(txData)
.then(() => {
clearConfirmTransaction()
this.setState({ submitting: false })
history.push(DEFAULT_ROUTE)
})
.catch(error => {
this.setState({ submitting: false, submitError: error.message })
})
}
this.setState({
submitting: true,
submitError: null,
}, () => {
if (onSubmit) {
Promise.resolve(onSubmit(txData))
.then(() => {
this.setState({
submitting: false,
})
})
} else {
sendTransaction(txData)
.then(() => {
clearConfirmTransaction()
this.setState({
submitting: false,
}, () => {
history.push(DEFAULT_ROUTE)
})
})
.catch(error => {
this.setState({
submitting: false,
submitError: error.message,
})
})
}
})
}
renderTitleComponent () {