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
This commit is contained in:
parent
7cb817c7bc
commit
27828a3785
1 changed files with 10 additions and 1 deletions
|
@ -641,10 +641,19 @@ module.exports = createReactClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_calculateOpsPermissions: async function(member) {
|
_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 = {
|
const defaultPerms = {
|
||||||
can: {
|
can: {
|
||||||
// Calculate permissions for Synapse before doing the PL checks
|
// Calculate permissions for Synapse before doing the PL checks
|
||||||
synapseDeactivate: await this.context.matrixClient.isSynapseAdministrator(),
|
synapseDeactivate: canDeactivate,
|
||||||
},
|
},
|
||||||
muted: false,
|
muted: false,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue