From 8abb7ebc65120300c1b33df273652eab0a78cb76 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 1 Feb 2019 14:35:03 +0100 Subject: [PATCH] monitor device verification in RoomView and update e2eStatus --- src/components/structures/RoomView.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 01df8272fa..9718ef0ef6 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -168,6 +168,7 @@ module.exports = React.createClass({ MatrixClientPeg.get().on("Room.myMembership", this.onMyMembership); MatrixClientPeg.get().on("accountData", this.onAccountData); MatrixClientPeg.get().on("crypto.keyBackupStatus", this.onKeyBackupStatus); + MatrixClientPeg.get().on("deviceVerificationChanged", this.onDeviceVerificationChanged); this._fetchMediaConfig(); // Start listening for RoomViewStore updates this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate); @@ -457,6 +458,7 @@ module.exports = React.createClass({ MatrixClientPeg.get().removeListener("RoomState.members", this.onRoomStateMember); MatrixClientPeg.get().removeListener("accountData", this.onAccountData); MatrixClientPeg.get().removeListener("crypto.keyBackupStatus", this.onKeyBackupStatus); + MatrixClientPeg.get().removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged); } window.removeEventListener('beforeunload', this.onPageUnload); @@ -642,6 +644,7 @@ module.exports = React.createClass({ this._updatePreviewUrlVisibility(room); this._loadMembersIfJoined(room); this._calculateRecommendedVersion(room); + this._updateE2EStatus(room); }, _calculateRecommendedVersion: async function(room) { @@ -733,6 +736,23 @@ module.exports = React.createClass({ }); }, + onDeviceVerificationChanged: function(userId, device) { + const room = this.state.room; + if (!MatrixClientPeg.get().isRoomEncrypted(room.roomId)) { + return; + } + if (!room.currentState.getMember(userId)) { + return; + } + this._updateE2EStatus(room); + }, + + _updateE2EStatus: function(room) { + room.hasUnverifiedDevices().then((hasUnverifiedDevices) => { + this.setState({e2eStatus: hasUnverifiedDevices ? "warning" : "verified"}); + }); + }, + updateTint: function() { const room = this.state.room; if (!room) return; @@ -1575,6 +1595,7 @@ module.exports = React.createClass({ room={this.state.room} oobData={this.props.oobData} collapsedRhs={this.props.collapsedRhs} + e2eStatus={this.state.e2eStatus} />
@@ -1622,6 +1643,7 @@ module.exports = React.createClass({ ref="header" room={this.state.room} collapsedRhs={this.props.collapsedRhs} + e2eStatus={this.state.e2eStatus} />
@@ -1767,6 +1789,7 @@ module.exports = React.createClass({ disabled={this.props.disabled} showApps={this.state.showApps} uploadAllowed={this.isFileUploadAllowed} + e2eStatus={this.state.e2eStatus} />; } @@ -1917,6 +1940,7 @@ module.exports = React.createClass({ onCancelClick={(aux && !hideCancel) ? this.onCancelClick : null} onForgetClick={(myMembership === "leave") ? this.onForgetClick : null} onLeaveClick={(myMembership === "join") ? this.onLeaveClick : null} + e2eStatus={this.state.e2eStatus} />