Refactor onOk to async function
This commit is contained in:
parent
a6cc0406dd
commit
ba3dd0c87a
1 changed files with 13 additions and 11 deletions
|
@ -47,19 +47,17 @@ export default class DeactivateAccountDialog extends React.Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onOk() {
|
async _onOk() {
|
||||||
// This assumes that the HS requires password UI auth
|
// This assumes that the HS requires password UI auth
|
||||||
// for this endpoint. In reality it could be any UI auth.
|
// for this endpoint. In reality it could be any UI auth.
|
||||||
this.setState({busy: true});
|
this.setState({busy: true});
|
||||||
MatrixClientPeg.get().deactivateAccount({
|
try {
|
||||||
type: 'm.login.password',
|
await MatrixClientPeg.get().deactivateAccount({
|
||||||
user: MatrixClientPeg.get().credentials.userId,
|
type: 'm.login.password',
|
||||||
password: this._passwordField.value,
|
user: MatrixClientPeg.get().credentials.userId,
|
||||||
}).done(() => {
|
password: this._passwordField.value,
|
||||||
Analytics.trackEvent('Account', 'Deactivate Account');
|
});
|
||||||
Lifecycle.onLoggedOut();
|
} catch (err) {
|
||||||
this.props.onFinished(false);
|
|
||||||
}, (err) => {
|
|
||||||
let errStr = _t('Unknown error');
|
let errStr = _t('Unknown error');
|
||||||
// https://matrix.org/jira/browse/SYN-744
|
// https://matrix.org/jira/browse/SYN-744
|
||||||
if (err.httpStatus == 401 || err.httpStatus == 403) {
|
if (err.httpStatus == 401 || err.httpStatus == 403) {
|
||||||
|
@ -70,7 +68,11 @@ export default class DeactivateAccountDialog extends React.Component {
|
||||||
busy: false,
|
busy: false,
|
||||||
errStr: errStr,
|
errStr: errStr,
|
||||||
});
|
});
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
|
Analytics.trackEvent('Account', 'Deactivate Account');
|
||||||
|
Lifecycle.onLoggedOut();
|
||||||
|
this.props.onFinished(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onCancel() {
|
_onCancel() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue