diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 5dd460d74a..494792d902 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -392,10 +392,10 @@ module.exports = React.createClass({ }); break; case 'view_room': - // Takes both room ID and room alias: if switching to a room the client is already - // know to be in (eg. user clicks on a room in the recents panel), supply only the - // ID. If the user is clicking on a room in the context of the alias being presented - // to them, supply the room alias and optionally the room ID. + // Takes either a room ID or room alias: if switching to a room the client is already + // known to be in (eg. user clicks on a room in the recents panel), supply the ID + // If the user is clicking on a room in the context of the alias being presented + // to them, supply the room alias. If both are supplied, the room ID will be ignored. this._viewRoom( payload.room_id, payload.room_alias, payload.show_settings, payload.event_id, payload.third_party_invite, payload.oob_data @@ -507,9 +507,12 @@ module.exports = React.createClass({ thirdPartyInvite: thirdPartyInvite, roomOobData: oob_data, currentRoomAlias: roomAlias, - currentRoomId: roomId, }; + if (!roomAlias) { + newState.currentRoomId = roomId; + } + // if we aren't given an explicit event id, look for one in the // scrollStateMap. if (!eventId) { @@ -982,6 +985,13 @@ module.exports = React.createClass({ } }, + onRoomIdResolved: function(room_id) { + // It's the RoomView's resposibility to look up room aliases, but we need the + // ID to pass into things like the Member List, so the Room View tells us when + // its done that resolution so we can display things that take a room ID. + this.setState({currentRoomId: room_id}); + }, + render: function() { var LeftPanel = sdk.getComponent('structures.LeftPanel'); var RoomView = sdk.getComponent('structures.RoomView'); @@ -1013,12 +1023,13 @@ module.exports = React.createClass({ ); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index d840630760..4a3d3e7a31 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -61,6 +61,11 @@ module.exports = React.createClass({ // ID should be supplied. roomAddress: React.PropTypes.string.isRequired, + // If a room alias is passed to roomAddress, a function can be + // provided here that will be called with the ID of the room + // once it has been resolved. + onRoomIdResolved: React.PropTypes.func, + // An object representing a third party invite to join this room // Fields: // * inviteSignUrl (string) The URL used to join this room from an email invite @@ -151,9 +156,14 @@ module.exports = React.createClass({ // right now. We may have joined that alias before but there's // no guarantee the alias hasn't subsequently been remapped. MatrixClientPeg.get().getRoomIdForAlias(this.props.roomAddress).done((result) => { + if (this.props.onRoomIdResolved) { + this.props.onRoomIdResolved(result.room_id); + } + var room = MatrixClientPeg.get().getRoom(result.room_id); this.setState({ + room: room, roomId: result.room_id, - roomLoading: false, + roomLoading: !room, }, this.updatePeeking); }, (err) => { this.setState({