mirror of https://github.com/vector-im/riot-web
Merge pull request #995 from matrix-org/luke/new-guest-access-fix-wrong-room-shown
Fix to show the correct roompull/21833/head
commit
d81160d52f
|
@ -171,7 +171,7 @@ module.exports = React.createClass({
|
|||
});
|
||||
|
||||
// Start listening for RoomViewStore updates
|
||||
RoomViewStore.addListener(this._onRoomViewStoreUpdate);
|
||||
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate);
|
||||
this._onRoomViewStoreUpdate(true);
|
||||
},
|
||||
|
||||
|
@ -182,6 +182,8 @@ module.exports = React.createClass({
|
|||
this.setState({
|
||||
roomId: RoomViewStore.getRoomId(),
|
||||
roomAlias: RoomViewStore.getRoomAlias(),
|
||||
roomLoading: RoomViewStore.isRoomLoading(),
|
||||
roomLoadError: RoomViewStore.getRoomLoadError(),
|
||||
joining: RoomViewStore.isJoining(),
|
||||
joinError: RoomViewStore.getJoinError(),
|
||||
}, () => {
|
||||
|
@ -343,6 +345,11 @@ module.exports = React.createClass({
|
|||
|
||||
document.removeEventListener("keydown", this.onKeyDown);
|
||||
|
||||
// Remove RoomStore listener
|
||||
if (this._roomStoreToken) {
|
||||
this._roomStoreToken.remove();
|
||||
}
|
||||
|
||||
// cancel any pending calls to the rate_limited_funcs
|
||||
this._updateRoomMembers.cancelPendingCall();
|
||||
|
||||
|
|
|
@ -58,6 +58,9 @@ class RoomViewStore extends Store {
|
|||
case 'view_room':
|
||||
this._viewRoom(payload);
|
||||
break;
|
||||
case 'view_room_error':
|
||||
this._viewRoomError(payload);
|
||||
break;
|
||||
case 'will_join':
|
||||
this._setState({
|
||||
joining: true,
|
||||
|
@ -80,33 +83,47 @@ class RoomViewStore extends Store {
|
|||
}
|
||||
|
||||
_viewRoom(payload) {
|
||||
const address = payload.room_alias || payload.room_id;
|
||||
if (address[0] == '#') {
|
||||
// Always set the room ID if present
|
||||
if (payload.room_id) {
|
||||
this._setState({
|
||||
roomLoading: true,
|
||||
roomId: payload.room_id,
|
||||
roomLoading: false,
|
||||
roomLoadError: null,
|
||||
});
|
||||
MatrixClientPeg.get().getRoomIdForAlias(address).then(
|
||||
} else if (payload.room_alias) {
|
||||
this._setState({
|
||||
roomId: null,
|
||||
roomAlias: payload.room_alias,
|
||||
roomLoading: true,
|
||||
roomLoadError: null,
|
||||
});
|
||||
MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias).done(
|
||||
(result) => {
|
||||
this._setState({
|
||||
roomId: result.room_id,
|
||||
roomAlias: address,
|
||||
roomLoading: false,
|
||||
roomLoadError: null,
|
||||
dis.dispatch({
|
||||
action: 'view_room',
|
||||
room_id: result.room_id,
|
||||
room_alias: payload.room_alias,
|
||||
});
|
||||
}, (err) => {
|
||||
console.error(err);
|
||||
this._setState({
|
||||
roomLoading: false,
|
||||
roomLoadError: err,
|
||||
dis.dispatch({
|
||||
action: 'view_room_error',
|
||||
room_id: null,
|
||||
room_alias: payload.room_alias,
|
||||
err: err,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this._setState({
|
||||
roomId: address,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_viewRoomError(payload) {
|
||||
this._setState({
|
||||
roomId: payload.room_id,
|
||||
roomAlias: payload.room_alias,
|
||||
roomLoading: false,
|
||||
roomLoadError: payload.err,
|
||||
});
|
||||
}
|
||||
|
||||
_joinRoom(payload) {
|
||||
this._setState({
|
||||
joining: true,
|
||||
|
@ -140,6 +157,10 @@ class RoomViewStore extends Store {
|
|||
return this._state.roomLoading;
|
||||
}
|
||||
|
||||
getRoomLoadError() {
|
||||
return this._state.roomLoadError;
|
||||
}
|
||||
|
||||
isJoining() {
|
||||
return this._state.joining;
|
||||
}
|
||||
|
|
|
@ -45,12 +45,15 @@ describe('RoomViewStore', function() {
|
|||
done();
|
||||
};
|
||||
|
||||
dispatch({ action: 'view_room', room_alias: '#somealias2:aser.ver' });
|
||||
RoomViewStore.addListener(() => {
|
||||
// Wait until the room alias has resolved and the room ID is
|
||||
if (!RoomViewStore.isRoomLoading()) {
|
||||
expect(RoomViewStore.getRoomId()).toBe("!randomcharacters:aser.ver");
|
||||
dispatch({ action: 'join_room' });
|
||||
expect(RoomViewStore.isJoining()).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
// Wait for the next event loop to allow for room alias resolution
|
||||
setTimeout(() => {
|
||||
dispatch({ action: 'join_room' });
|
||||
expect(RoomViewStore.isJoining()).toBe(true);
|
||||
}, 0);
|
||||
dispatch({ action: 'view_room', room_alias: '#somealias2:aser.ver' });
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue