From bf348a0f7879dd65100cdc5fe3e06f800fd36f48 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Mon, 6 Mar 2017 17:44:29 +0000 Subject: [PATCH] Instead of listening for view_room, use a callback But make sure that nothing other than the callback is done when RoomTile is clicked. --- .../views/dialogs/ChatCreateOrReuseDialog.js | 30 ++++++++----------- src/components/views/rooms/MemberInfo.js | 8 +++++ src/components/views/rooms/RoomTile.js | 6 +--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/components/views/dialogs/ChatCreateOrReuseDialog.js b/src/components/views/dialogs/ChatCreateOrReuseDialog.js index 53c5113b5d..7761e25010 100644 --- a/src/components/views/dialogs/ChatCreateOrReuseDialog.js +++ b/src/components/views/dialogs/ChatCreateOrReuseDialog.js @@ -28,28 +28,23 @@ export default class CreateOrReuseChatDialog extends React.Component { constructor(props) { super(props); - this._onNewDMClick = this._onNewDMClick.bind(this); - this.dispatcherRef = dis.register(this._onAction.bind(this)); + this.onNewDMClick = this.onNewDMClick.bind(this); + this.onRoomTileClick = this.onRoomTileClick.bind(this); } - componentWillUnmount() { - dis.unregister(this.dispatcherRef); - } - - _onAction(payload) { - switch(payload.action) { - case 'view_room': - this.props.onFinished(true); - break; - default: - } - } - - _onNewDMClick() { + onNewDMClick() { createRoom({dmUserId: this.props.userId}); this.props.onFinished(true); } + onRoomTileClick(roomId) { + dis.dispatch({ + action: 'view_room', + room_id: roomId, + }); + this.props.onFinished(true); + } + render() { const client = MatrixClientPeg.get(); @@ -74,6 +69,7 @@ export default class CreateOrReuseChatDialog extends React.Component { unread={Unread.doesRoomHaveUnreadMessages(room)} highlight={highlight} isInvite={me.membership == "invite"} + onClick={this.onRoomTileClick} /> ); } @@ -85,7 +81,7 @@ export default class CreateOrReuseChatDialog extends React.Component { }); const startNewChat =
diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index 0c54565b9d..995453e9c1 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -553,6 +553,13 @@ module.exports = WithMatrixClient(React.createClass({ Modal.createDialog(ImageView, params, "mx_Dialog_lightbox"); }, + onRoomTileClick(roomId) { + dis.dispatch({ + action: 'view_room', + room_id: roomId, + }); + }, + _renderDevices: function() { if (!this._enableDevices) { return null; @@ -613,6 +620,7 @@ module.exports = WithMatrixClient(React.createClass({ unread={Unread.doesRoomHaveUnreadMessages(room)} highlight={highlight} isInvite={me.membership == "invite"} + onClick={this.onRoomTileClick} /> ); } diff --git a/src/components/views/rooms/RoomTile.js b/src/components/views/rooms/RoomTile.js index 485b567ddc..1fd293cae8 100644 --- a/src/components/views/rooms/RoomTile.js +++ b/src/components/views/rooms/RoomTile.js @@ -101,12 +101,8 @@ module.exports = React.createClass({ }, onClick: function() { - dis.dispatch({ - action: 'view_room', - room_id: this.props.room.roomId, - }); if (this.props.onClick) { - this.props.onClick(); + this.props.onClick(this.props.room.roomId); } },