From 27828a37851b00c5182b7420d2b50f059416f2fc Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 12 Sep 2019 18:30:27 -0600 Subject: [PATCH 1/3] 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 --- src/components/views/rooms/MemberInfo.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index dc9f1070fd..2c46583004 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -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, }; From d18d15311f967357143b41d5efb63d44c2e23f97 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 13 Sep 2019 12:43:47 -0600 Subject: [PATCH 2/3] Remove extraneous guard on deactivation check --- src/components/views/rooms/MemberInfo.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index 2c46583004..302682104c 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -643,11 +643,7 @@ 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); - } + canDeactivate = await this.context.matrixClient.isSynapseAdministrator(); } const defaultPerms = { From 3150d65bd79000f34fb4ccf762a477889c6b8c31 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 13 Sep 2019 12:43:57 -0600 Subject: [PATCH 3/3] De-async _calculateCanPermissions --- src/components/views/rooms/MemberInfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index 302682104c..93a3fdf75f 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -673,7 +673,7 @@ module.exports = createReactClass({ }; }, - _calculateCanPermissions: async function(me, them, powerLevels) { + _calculateCanPermissions: function(me, them, powerLevels) { const isMe = me.userId === them.userId; const can = { kick: false,