From 5551b207c1b50abb52a31692d726c456a429a9e3 Mon Sep 17 00:00:00 2001 From: Zoe Date: Fri, 10 Jan 2020 16:33:08 +0000 Subject: [PATCH] Actually, this task was about join rules, not encryption ones. Oops. --- res/css/views/rooms/_RoomTile.scss | 4 ++-- src/components/views/rooms/RoomTile.js | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/res/css/views/rooms/_RoomTile.scss b/res/css/views/rooms/_RoomTile.scss index 5c37492383..cb1137bb2f 100644 --- a/res/css/views/rooms/_RoomTile.scss +++ b/res/css/views/rooms/_RoomTile.scss @@ -201,12 +201,12 @@ limitations under the License. flex: 1; } -.mx_RoomTile.mx_RoomTile.mx_RoomTile_isEncrypted .mx_RoomTile_name { +.mx_RoomTile.mx_RoomTile.mx_RoomTile_isPrivate .mx_RoomTile_name { // Scoot the padding in a bit from 6px to make it look better padding-left: 3px; } -.mx_RoomTile.mx_RoomTile_isEncrypted .mx_RoomTile_E2EIcon { +.mx_RoomTile.mx_RoomTile_isPrivate .mx_RoomTile_PrivateIcon { width: 12px; height: 12px; position: relative; diff --git a/src/components/views/rooms/RoomTile.js b/src/components/views/rooms/RoomTile.js index ce0375e088..35b5d2fea5 100644 --- a/src/components/views/rooms/RoomTile.js +++ b/src/components/views/rooms/RoomTile.js @@ -56,7 +56,10 @@ module.exports = createReactClass({ }, getInitialState: function() { + const { event: { content: { join_rule } } } = this.props.room.currentState.getStateEvents("m.room.join_rules", ""); + return ({ + join_rule, hover: false, badgeHover: false, contextMenuPosition: null, // DOM bounding box, null if non-shown @@ -104,6 +107,14 @@ module.exports = createReactClass({ }); }, + onJoinRule: function(ev) { + const { event: { type, room_id } } = ev; + if (type !== "m.room.join_rules") return; + if (room_id !== this.props.room.roomId) return; + const { event: { content: { join_rule } } } = ev; + this.setState({ join_rule }); + }, + onAccountData: function(accountDataEvent) { if (accountDataEvent.getType() === 'm.push_rules') { this.setState({ @@ -143,6 +154,7 @@ module.exports = createReactClass({ const cli = MatrixClientPeg.get(); cli.on("accountData", this.onAccountData); cli.on("Room.name", this.onRoomName); + cli.on("RoomState.events", this.onJoinRule); ActiveRoomObserver.addListener(this.props.room.roomId, this._onActiveRoomChange); this.dispatcherRef = dis.register(this.onAction); @@ -159,6 +171,7 @@ module.exports = createReactClass({ if (cli) { MatrixClientPeg.get().removeListener("accountData", this.onAccountData); MatrixClientPeg.get().removeListener("Room.name", this.onRoomName); + cli.removeListener("RoomState.events", this.onJoinRule); } ActiveRoomObserver.removeListener(this.props.room.roomId, this._onActiveRoomChange); dis.unregister(this.dispatcherRef); @@ -303,7 +316,7 @@ module.exports = createReactClass({ 'mx_RoomTile_noBadges': !badges, 'mx_RoomTile_transparent': this.props.transparent, 'mx_RoomTile_hasSubtext': subtext && !this.props.collapsed, - 'mx_RoomTile_isEncrypted': Boolean(this.props.room.currentState.getStateEvents("m.room.encryption", "")), + 'mx_RoomTile_isPrivate': this.state.join_rule == "invite", }); const avatarClasses = classNames({ @@ -429,7 +442,7 @@ module.exports = createReactClass({ { dmIndicator } -
+
{ label }