Wrap deactivation check with sanity conditions

To ensure the matrixClient is not null (the problem) and that unexpected errors don't brick the app.

Fixes https://github.com/vector-im/riot-web/issues/10854
pull/21833/head
Travis Ralston 2019-09-12 18:30:27 -06:00
parent 3fef6e6b22
commit f4ebde1596
1 changed files with 10 additions and 1 deletions

View File

@ -636,10 +636,19 @@ module.exports = withMatrixClient(React.createClass({
},
_calculateOpsPermissions: async function(member) {
let canDeactivate = false;
if (this.context.matrixClient) {
try {
canDeactivate = await this.context.matrixClient.isSynapseAdministrator();
} catch (e) {
console.error(e);
}
}
const defaultPerms = {
can: {
// Calculate permissions for Synapse before doing the PL checks
synapseDeactivate: await this.context.matrixClient.isSynapseAdministrator(),
synapseDeactivate: canDeactivate,
},
muted: false,
};