Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Wrap deactivation check with sanity conditions
Browse files Browse the repository at this point in the history
To ensure the matrixClient is not null (the problem) and that unexpected errors don't brick the app.

Fixes element-hq/element-web#10854
  • Loading branch information
turt2live committed Sep 13, 2019
1 parent 7cb817c commit 27828a3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/views/rooms/MemberInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,19 @@ module.exports = createReactClass({
},

_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,
};
Expand Down

0 comments on commit 27828a3

Please sign in to comment.