1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +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 return
} }
this.setState({ submitting: true, submitError: null }) this.setState({
submitting: true,
if (onSubmit) { submitError: null,
Promise.resolve(onSubmit(txData)) }, () => {
.then(this.setState({ submitting: false })) if (onSubmit) {
} else { Promise.resolve(onSubmit(txData))
sendTransaction(txData) .then(() => {
.then(() => { this.setState({
clearConfirmTransaction() submitting: false,
this.setState({ submitting: false }) })
history.push(DEFAULT_ROUTE) })
}) } else {
.catch(error => { sendTransaction(txData)
this.setState({ submitting: false, submitError: error.message }) .then(() => {
}) clearConfirmTransaction()
} this.setState({
submitting: false,
}, () => {
history.push(DEFAULT_ROUTE)
})
})
.catch(error => {
this.setState({
submitting: false,
submitError: error.message,
})
})
}
})
} }
renderTitleComponent () { renderTitleComponent () {