Fix member list vanishing

Add a callback to RoomView that it can give the room ID to once it's resolved it, since this lookup is now the responsibility of the roomview and only the roomview. The view_room action now has either an alias or an ID, not both. Also fix RoomView to load the room properly and not try to peek when it shouldn't.
This commit is contained in:
David Baker 2016-06-14 12:56:37 +01:00
parent aaefdf19c5
commit b8eee08d69
2 changed files with 28 additions and 7 deletions

View file

@ -392,10 +392,10 @@ module.exports = React.createClass({
}); });
break; break;
case 'view_room': case 'view_room':
// Takes both room ID and room alias: if switching to a room the client is already // Takes either a room ID or 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 // known to be in (eg. user clicks on a room in the recents panel), supply the ID
// ID. If the user is clicking on a room in the context of the alias being presented // 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. // to them, supply the room alias. If both are supplied, the room ID will be ignored.
this._viewRoom( this._viewRoom(
payload.room_id, payload.room_alias, payload.show_settings, payload.event_id, payload.room_id, payload.room_alias, payload.show_settings, payload.event_id,
payload.third_party_invite, payload.oob_data payload.third_party_invite, payload.oob_data
@ -507,9 +507,12 @@ module.exports = React.createClass({
thirdPartyInvite: thirdPartyInvite, thirdPartyInvite: thirdPartyInvite,
roomOobData: oob_data, roomOobData: oob_data,
currentRoomAlias: roomAlias, currentRoomAlias: roomAlias,
currentRoomId: roomId,
}; };
if (!roomAlias) {
newState.currentRoomId = roomId;
}
// if we aren't given an explicit event id, look for one in the // if we aren't given an explicit event id, look for one in the
// scrollStateMap. // scrollStateMap.
if (!eventId) { 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() { render: function() {
var LeftPanel = sdk.getComponent('structures.LeftPanel'); var LeftPanel = sdk.getComponent('structures.LeftPanel');
var RoomView = sdk.getComponent('structures.RoomView'); var RoomView = sdk.getComponent('structures.RoomView');
@ -1013,12 +1023,13 @@ module.exports = React.createClass({
<RoomView <RoomView
ref="roomView" ref="roomView"
roomAddress={this.state.currentRoomAlias || this.state.currentRoomId} roomAddress={this.state.currentRoomAlias || this.state.currentRoomId}
onRoomIdResolved={this.onRoomIdResolved}
eventId={this.state.initialEventId} eventId={this.state.initialEventId}
thirdPartyInvite={this.state.thirdPartyInvite} thirdPartyInvite={this.state.thirdPartyInvite}
oobData={this.state.roomOobData} oobData={this.state.roomOobData}
highlightedEventId={this.state.highlightedEventId} highlightedEventId={this.state.highlightedEventId}
eventPixelOffset={this.state.initialEventPixelOffset} eventPixelOffset={this.state.initialEventPixelOffset}
key={this.state.currentRoomId || this.state.currentRoomAlias} key={this.state.currentRoomAlias || this.state.currentRoomId}
opacity={this.state.middleOpacity} opacity={this.state.middleOpacity}
ConferenceHandler={this.props.ConferenceHandler} /> ConferenceHandler={this.props.ConferenceHandler} />
); );

View file

@ -61,6 +61,11 @@ module.exports = React.createClass({
// ID should be supplied. // ID should be supplied.
roomAddress: React.PropTypes.string.isRequired, 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 // An object representing a third party invite to join this room
// Fields: // Fields:
// * inviteSignUrl (string) The URL used to join this room from an email invite // * 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 // right now. We may have joined that alias before but there's
// no guarantee the alias hasn't subsequently been remapped. // no guarantee the alias hasn't subsequently been remapped.
MatrixClientPeg.get().getRoomIdForAlias(this.props.roomAddress).done((result) => { 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({ this.setState({
room: room,
roomId: result.room_id, roomId: result.room_id,
roomLoading: false, roomLoading: !room,
}, this.updatePeeking); }, this.updatePeeking);
}, (err) => { }, (err) => {
this.setState({ this.setState({