More PR feedback

Unmounted guards, extra semicolon, return early to lose indent
level, add keys.
pull/21833/head
David Baker 2017-03-22 16:41:08 +00:00
parent 6b78440466
commit b58d8bffe1
1 changed files with 35 additions and 31 deletions

View File

@ -86,8 +86,9 @@ export default WithMatrixClient(React.createClass({
description: msg, description: msg,
}); });
}).finally(() => { }).finally(() => {
if (this._unmounted) return;
this.setState({msisdn_add_pending: false}); this.setState({msisdn_add_pending: false});
}).done();; }).done();
this._addMsisdnInput.blur(); this._addMsisdnInput.blur();
this.setState({msisdn_add_pending: true}); this.setState({msisdn_add_pending: true});
}, },
@ -96,7 +97,7 @@ export default WithMatrixClient(React.createClass({
if (this._unmounted) return; if (this._unmounted) return;
const TextInputDialog = sdk.getComponent("dialogs.TextInputDialog"); const TextInputDialog = sdk.getComponent("dialogs.TextInputDialog");
let msgElements = [ let msgElements = [
<div>A text message has been sent to +{msisdn}. <div key="_static" >A text message has been sent to +{msisdn}.
Please enter the verification code it contains</div> Please enter the verification code it contains</div>
]; ];
if (err) { if (err) {
@ -104,7 +105,7 @@ export default WithMatrixClient(React.createClass({
if (err.errcode == 'M_THREEPID_AUTH_FAILED') { if (err.errcode == 'M_THREEPID_AUTH_FAILED') {
msg = "Incorrect verification code"; msg = "Incorrect verification code";
} }
msgElements.push(<div className="error">{msg}</div>); msgElements.push(<div key="_error" className="error">{msg}</div>);
} }
Modal.createDialog(TextInputDialog, { Modal.createDialog(TextInputDialog, {
title: "Enter Code", title: "Enter Code",
@ -123,6 +124,7 @@ export default WithMatrixClient(React.createClass({
}).catch((err) => { }).catch((err) => {
this._promptForMsisdnVerificationCode(msisdn, err); this._promptForMsisdnVerificationCode(msisdn, err);
}).finally(() => { }).finally(() => {
if (this._unmounted) return;
this.setState({msisdn_add_pending: false}); this.setState({msisdn_add_pending: false});
}).done(); }).done();
} }
@ -133,7 +135,10 @@ export default WithMatrixClient(React.createClass({
const Loader = sdk.getComponent("elements.Spinner"); const Loader = sdk.getComponent("elements.Spinner");
if (this.state.msisdn_add_pending) { if (this.state.msisdn_add_pending) {
return <Loader />; return <Loader />;
} else if (!this.props.matrixClient.isGuest()) { } else if (this.props.matrixClient.isGuest()) {
return null;
}
const CountryDropdown = sdk.getComponent('views.login.CountryDropdown'); const CountryDropdown = sdk.getComponent('views.login.CountryDropdown');
// XXX: This CSS relies on the CSS surrounding it in UserSettings as its in // XXX: This CSS relies on the CSS surrounding it in UserSettings as its in
// a tabular format to align the submit buttons // a tabular format to align the submit buttons
@ -162,5 +167,4 @@ export default WithMatrixClient(React.createClass({
</form> </form>
); );
} }
}
})) }))