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} />