Update all 3PID state in Settings when IS changes
This ensures we update all 3PID state (like bind status) whenever the IS changes.
This commit is contained in:
parent
0b7995dc11
commit
db33c138aa
3 changed files with 25 additions and 9 deletions
|
@ -58,6 +58,11 @@ export class EmailAddress extends React.Component {
|
|||
};
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { bound } = nextProps.email;
|
||||
this.setState({ bound });
|
||||
}
|
||||
|
||||
async changeBinding({ bind, label, errorTitle }) {
|
||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||
const { medium, address } = this.props.email;
|
||||
|
|
|
@ -50,6 +50,11 @@ export class PhoneNumber extends React.Component {
|
|||
};
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { bound } = nextProps.msisdn;
|
||||
this.setState({ bound });
|
||||
}
|
||||
|
||||
async changeBinding({ bind, label, errorTitle }) {
|
||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||
const { medium, address } = this.props.msisdn;
|
||||
|
|
|
@ -72,14 +72,7 @@ export default class GeneralUserSettingsTab extends React.Component {
|
|||
const serverRequiresIdServer = await cli.doesServerRequireIdServerParam();
|
||||
this.setState({serverRequiresIdServer});
|
||||
|
||||
// Check to see if terms need accepting
|
||||
this._checkTerms();
|
||||
|
||||
// Need to get 3PIDs generally for Account section and possibly also for
|
||||
// Discovery (assuming we have an IS and terms are agreed).
|
||||
const threepids = await getThreepidsWithBindStatus(cli);
|
||||
this.setState({ emails: threepids.filter((a) => a.medium === 'email') });
|
||||
this.setState({ msisdns: threepids.filter((a) => a.medium === 'msisdn') });
|
||||
this._getThreepidState();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
@ -89,7 +82,7 @@ export default class GeneralUserSettingsTab extends React.Component {
|
|||
_onAction = (payload) => {
|
||||
if (payload.action === 'id_server_changed') {
|
||||
this.setState({haveIdServer: Boolean(MatrixClientPeg.get().getIdentityServerUrl())});
|
||||
this._checkTerms();
|
||||
this._getThreepidState();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -101,6 +94,19 @@ export default class GeneralUserSettingsTab extends React.Component {
|
|||
this.setState({ msisdns });
|
||||
}
|
||||
|
||||
async _getThreepidState() {
|
||||
const cli = MatrixClientPeg.get();
|
||||
|
||||
// Check to see if terms need accepting
|
||||
this._checkTerms();
|
||||
|
||||
// Need to get 3PIDs generally for Account section and possibly also for
|
||||
// Discovery (assuming we have an IS and terms are agreed).
|
||||
const threepids = await getThreepidsWithBindStatus(cli);
|
||||
this.setState({ emails: threepids.filter((a) => a.medium === 'email') });
|
||||
this.setState({ msisdns: threepids.filter((a) => a.medium === 'msisdn') });
|
||||
}
|
||||
|
||||
async _checkTerms() {
|
||||
if (!this.state.haveIdServer) {
|
||||
this.setState({idServerHasUnsignedTerms: false});
|
||||
|
|
Loading…
Reference in a new issue