Convert to old style react class

pull/21833/head
David Baker 2017-03-22 16:15:45 +00:00
parent cca607d469
commit e39979a61f
1 changed files with 29 additions and 38 deletions

View File

@ -22,51 +22,50 @@ import WithMatrixClient from '../../../wrappers/WithMatrixClient';
import Modal from '../../../Modal'; import Modal from '../../../Modal';
class AddPhoneNumber extends React.Component { export default WithMatrixClient(React.createClass({
constructor(props, context) { displayName: 'AddPhoneNumber',
super(props, context);
this._addThreepid = null; propTypes: {
this._addMsisdnInput = null; matrixClient: React.PropTypes.object.isRequired,
onThreepidAdded: React.PropTypes.func,
},
this.state = { getInitialState: function() {
return {
busy: false, busy: false,
phoneCountry: null, phoneCountry: null,
phoneNumber: "", phoneNumber: "",
}; };
},
this._onPhoneCountryChange = this._onPhoneCountryChange.bind(this); componentWillMount: function() {
this._onPhoneNumberChange = this._onPhoneNumberChange.bind(this); this._addThreepid = null;
this._onAddMsisdnEditFinished = this._onAddMsisdnEditFinished.bind(this); this._addMsisdnInput = null;
this._onAddMsisdnSubmit = this._onAddMsisdnSubmit.bind(this); },
this._collectAddMsisdnInput = this._collectAddMsisdnInput.bind(this);
this._addMsisdn = this._addMsisdn.bind(this);
this._promptForMsisdnVerificationCode = this._promptForMsisdnVerificationCode.bind(this);
}
_onPhoneCountryChange(phoneCountry) { _onPhoneCountryChange: function(phoneCountry) {
this.setState({ phoneCountry: phoneCountry }); this.setState({ phoneCountry: phoneCountry });
} },
_onPhoneNumberChange(ev) { _onPhoneNumberChange: function(ev) {
this.setState({ phoneNumber: ev.target.value }); this.setState({ phoneNumber: ev.target.value });
} },
_onAddMsisdnEditFinished(value, shouldSubmit) { _onAddMsisdnEditFinished: function(value, shouldSubmit) {
if (!shouldSubmit) return; if (!shouldSubmit) return;
this._addMsisdn(); this._addMsisdn();
} },
_onAddMsisdnSubmit(ev) { _onAddMsisdnSubmit: function(ev) {
ev.preventDefault(); ev.preventDefault();
this._addMsisdn(); this._addMsisdn();
} },
_collectAddMsisdnInput(e) { _collectAddMsisdnInput: function(e) {
this._addMsisdnInput = e; this._addMsisdnInput = e;
} },
_addMsisdn() { _addMsisdn: function() {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
@ -87,9 +86,9 @@ class AddPhoneNumber extends React.Component {
}).done();; }).done();;
this._addMsisdnInput.blur(); this._addMsisdnInput.blur();
this.setState({msisdn_add_pending: true}); this.setState({msisdn_add_pending: true});
} },
_promptForMsisdnVerificationCode(msisdn, err) { _promptForMsisdnVerificationCode:function (msisdn, err) {
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>A text message has been sent to +{msisdn}.
@ -123,9 +122,9 @@ class AddPhoneNumber extends React.Component {
}).done(); }).done();
} }
}); });
} },
render() { render: function() {
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 />;
@ -159,12 +158,4 @@ class AddPhoneNumber extends React.Component {
); );
} }
} }
} }))
AddPhoneNumber.propTypes = {
matrixClient: React.PropTypes.object.isRequired,
onThreepidAdded: React.PropTypes.func,
};
AddPhoneNumber = WithMatrixClient(AddPhoneNumber);
export default AddPhoneNumber;