Catch errors in Settings when IS is unreachable
A few bits of Settings try to talk to the IS when Settings is opened. This changes them to handle failure by logging warnings to the console.pull/21833/head
parent
6e33cc0650
commit
d7631ed9f8
|
@ -102,7 +102,17 @@ export default class GeneralUserSettingsTab extends React.Component {
|
||||||
|
|
||||||
// Need to get 3PIDs generally for Account section and possibly also for
|
// Need to get 3PIDs generally for Account section and possibly also for
|
||||||
// Discovery (assuming we have an IS and terms are agreed).
|
// Discovery (assuming we have an IS and terms are agreed).
|
||||||
const threepids = await getThreepidsWithBindStatus(cli);
|
let threepids = [];
|
||||||
|
try {
|
||||||
|
threepids = await getThreepidsWithBindStatus(cli);
|
||||||
|
} catch (e) {
|
||||||
|
const idServerUrl = MatrixClientPeg.get().getIdentityServerUrl();
|
||||||
|
console.warn(
|
||||||
|
`Unable to reach identity server at ${idServerUrl} to check ` +
|
||||||
|
`for 3PIDs bindings in Settings`,
|
||||||
|
);
|
||||||
|
console.warn(e);
|
||||||
|
}
|
||||||
this.setState({ emails: threepids.filter((a) => a.medium === 'email') });
|
this.setState({ emails: threepids.filter((a) => a.medium === 'email') });
|
||||||
this.setState({ msisdns: threepids.filter((a) => a.medium === 'msisdn') });
|
this.setState({ msisdns: threepids.filter((a) => a.medium === 'msisdn') });
|
||||||
}
|
}
|
||||||
|
@ -115,32 +125,40 @@ export default class GeneralUserSettingsTab extends React.Component {
|
||||||
|
|
||||||
// By starting the terms flow we get the logic for checking which terms the user has signed
|
// By starting the terms flow we get the logic for checking which terms the user has signed
|
||||||
// for free. So we might as well use that for our own purposes.
|
// for free. So we might as well use that for our own purposes.
|
||||||
|
const idServerUrl = MatrixClientPeg.get().getIdentityServerUrl();
|
||||||
const authClient = new IdentityAuthClient();
|
const authClient = new IdentityAuthClient();
|
||||||
const idAccessToken = await authClient.getAccessToken({ check: false });
|
const idAccessToken = await authClient.getAccessToken({ check: false });
|
||||||
startTermsFlow([new Service(
|
try {
|
||||||
SERVICE_TYPES.IS,
|
await startTermsFlow([new Service(
|
||||||
MatrixClientPeg.get().getIdentityServerUrl(),
|
SERVICE_TYPES.IS,
|
||||||
idAccessToken,
|
idServerUrl,
|
||||||
)], (policiesAndServices, agreedUrls, extraClassNames) => {
|
idAccessToken,
|
||||||
return new Promise((resolve, reject) => {
|
)], (policiesAndServices, agreedUrls, extraClassNames) => {
|
||||||
this.setState({
|
return new Promise((resolve, reject) => {
|
||||||
idServerName: abbreviateUrl(MatrixClientPeg.get().getIdentityServerUrl()),
|
this.setState({
|
||||||
requiredPolicyInfo: {
|
idServerName: abbreviateUrl(idServerUrl),
|
||||||
hasTerms: true,
|
requiredPolicyInfo: {
|
||||||
policiesAndServices,
|
hasTerms: true,
|
||||||
agreedUrls,
|
policiesAndServices,
|
||||||
resolve,
|
agreedUrls,
|
||||||
},
|
resolve,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}).then(() => {
|
|
||||||
// User accepted all terms
|
// User accepted all terms
|
||||||
this.setState({
|
this.setState({
|
||||||
requiredPolicyInfo: {
|
requiredPolicyInfo: {
|
||||||
hasTerms: false,
|
hasTerms: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
} catch (e) {
|
||||||
|
console.warn(
|
||||||
|
`Unable to reach identity server at ${idServerUrl} to check ` +
|
||||||
|
`for terms in Settings`,
|
||||||
|
);
|
||||||
|
console.warn(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onLanguageChange = (newLanguage) => {
|
_onLanguageChange = (newLanguage) => {
|
||||||
|
|
Loading…
Reference in New Issue