From 30168a1b9c60fcda80512e8711ad3a945e5343fb Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 17 Aug 2016 09:57:06 +0100 Subject: [PATCH 1/2] Don't download E2E devices if feature disabled If the user hasn't enabled the E2E setting in the labs, there is no point in firing off the device download request when the MemberInfo is opened. --- src/components/views/rooms/MemberInfo.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index 0b37847257..b3c61ce807 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -73,6 +73,11 @@ module.exports = React.createClass({ }, componentDidMount: function() { + // only display the devices list if our client supports E2E *and* the + // feature is enabled in the user settings + this._enableDevices = MatrixClientPeg.get().isCryptoEnabled() && + UserSettingsStore.isFeatureEnabled("e2e_encryption"); + this._updateStateForNewMember(this.props.member); MatrixClientPeg.get().on("deviceVerificationChanged", this.onDeviceVerificationChanged); }, @@ -147,6 +152,10 @@ module.exports = React.createClass({ }, onDeviceVerificationChanged: function(userId, device) { + if (!this._enableDevices) { + return; + } + if (userId == this.props.member.userId) { // no need to re-download the whole thing; just update our copy of // the list. @@ -170,6 +179,10 @@ module.exports = React.createClass({ }, _downloadDeviceList: function(member) { + if (!this._enableDevices) { + return; + } + var cancelled = false; this._cancelDeviceList = function() { cancelled = true; } @@ -532,7 +545,7 @@ module.exports = React.createClass({ }, _renderDevices: function() { - if (!UserSettingsStore.isFeatureEnabled("e2e_encryption")) { + if (!this._enableDevices) { return null; } From 0356f04b9c8378b9657f83e484cf6d85f954b9d4 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 17 Aug 2016 14:40:10 +0100 Subject: [PATCH 2/2] MemberInfo: initialise _enableDevices in componentWillMount ... to avoid referencing it in render() before it is set --- src/components/views/rooms/MemberInfo.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index b3c61ce807..59e186da06 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -67,17 +67,17 @@ module.exports = React.createClass({ componentWillMount: function() { this._cancelDeviceList = null; + // only display the devices list if our client supports E2E *and* the + // feature is enabled in the user settings + this._enableDevices = MatrixClientPeg.get().isCryptoEnabled() && + UserSettingsStore.isFeatureEnabled("e2e_encryption"); + this.setState({ existingOneToOneRoomId: this.getExistingOneToOneRoomId() }); }, componentDidMount: function() { - // only display the devices list if our client supports E2E *and* the - // feature is enabled in the user settings - this._enableDevices = MatrixClientPeg.get().isCryptoEnabled() && - UserSettingsStore.isFeatureEnabled("e2e_encryption"); - this._updateStateForNewMember(this.props.member); MatrixClientPeg.get().on("deviceVerificationChanged", this.onDeviceVerificationChanged); },