Instead of listening for view_room, use a callback
But make sure that nothing other than the callback is done when RoomTile is clicked.
This commit is contained in:
parent
20fa36325f
commit
bf348a0f78
3 changed files with 22 additions and 22 deletions
|
@ -28,28 +28,23 @@ export default class CreateOrReuseChatDialog extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this._onNewDMClick = this._onNewDMClick.bind(this);
|
this.onNewDMClick = this.onNewDMClick.bind(this);
|
||||||
this.dispatcherRef = dis.register(this._onAction.bind(this));
|
this.onRoomTileClick = this.onRoomTileClick.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
onNewDMClick() {
|
||||||
dis.unregister(this.dispatcherRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
_onAction(payload) {
|
|
||||||
switch(payload.action) {
|
|
||||||
case 'view_room':
|
|
||||||
this.props.onFinished(true);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_onNewDMClick() {
|
|
||||||
createRoom({dmUserId: this.props.userId});
|
createRoom({dmUserId: this.props.userId});
|
||||||
this.props.onFinished(true);
|
this.props.onFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onRoomTileClick(roomId) {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'view_room',
|
||||||
|
room_id: roomId,
|
||||||
|
});
|
||||||
|
this.props.onFinished(true);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
|
|
||||||
|
@ -74,6 +69,7 @@ export default class CreateOrReuseChatDialog extends React.Component {
|
||||||
unread={Unread.doesRoomHaveUnreadMessages(room)}
|
unread={Unread.doesRoomHaveUnreadMessages(room)}
|
||||||
highlight={highlight}
|
highlight={highlight}
|
||||||
isInvite={me.membership == "invite"}
|
isInvite={me.membership == "invite"}
|
||||||
|
onClick={this.onRoomTileClick}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +81,7 @@ export default class CreateOrReuseChatDialog extends React.Component {
|
||||||
});
|
});
|
||||||
const startNewChat = <AccessibleButton
|
const startNewChat = <AccessibleButton
|
||||||
className="mx_MemberInfo_createRoom"
|
className="mx_MemberInfo_createRoom"
|
||||||
onClick={this._onNewDMClick}
|
onClick={this.onNewDMClick}
|
||||||
>
|
>
|
||||||
<div className="mx_RoomTile_avatar">
|
<div className="mx_RoomTile_avatar">
|
||||||
<img src="img/create-big.svg" width="26" height="26" />
|
<img src="img/create-big.svg" width="26" height="26" />
|
||||||
|
|
|
@ -553,6 +553,13 @@ module.exports = WithMatrixClient(React.createClass({
|
||||||
Modal.createDialog(ImageView, params, "mx_Dialog_lightbox");
|
Modal.createDialog(ImageView, params, "mx_Dialog_lightbox");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRoomTileClick(roomId) {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'view_room',
|
||||||
|
room_id: roomId,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
_renderDevices: function() {
|
_renderDevices: function() {
|
||||||
if (!this._enableDevices) {
|
if (!this._enableDevices) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -613,6 +620,7 @@ module.exports = WithMatrixClient(React.createClass({
|
||||||
unread={Unread.doesRoomHaveUnreadMessages(room)}
|
unread={Unread.doesRoomHaveUnreadMessages(room)}
|
||||||
highlight={highlight}
|
highlight={highlight}
|
||||||
isInvite={me.membership == "invite"}
|
isInvite={me.membership == "invite"}
|
||||||
|
onClick={this.onRoomTileClick}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,12 +101,8 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onClick: function() {
|
onClick: function() {
|
||||||
dis.dispatch({
|
|
||||||
action: 'view_room',
|
|
||||||
room_id: this.props.room.roomId,
|
|
||||||
});
|
|
||||||
if (this.props.onClick) {
|
if (this.props.onClick) {
|
||||||
this.props.onClick();
|
this.props.onClick(this.props.room.roomId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue