Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 02217c8

Browse files
authored
Merge pull request #1290 from matrix-org/luke/fix-user-url-no-middle-panel
At /user, view member of current room
2 parents 12966d0 + 89254e7 commit 02217c8

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

src/components/structures/LoggedInView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,13 @@ export default React.createClass({
301301

302302
case PageTypes.UserView:
303303
page_element = null; // deliberately null for now
304-
right_panel = <RightPanel userId={this.props.viewUserId} opacity={this.props.rightOpacity} />;
304+
right_panel = <RightPanel opacity={this.props.rightOpacity} />;
305305
break;
306306
case PageTypes.GroupView:
307307
page_element = <GroupView
308308
groupId={this.props.currentGroupId}
309309
/>;
310-
//right_panel = <RightPanel userId={this.props.viewUserId} opacity={this.props.rightOpacity} />;
310+
//right_panel = <RightPanel opacity={this.props.rightOpacity} />;
311311
break;
312312
}
313313

src/components/structures/MatrixChat.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ module.exports = React.createClass({
448448
});
449449
}, 0);
450450
}
451+
this.notifyNewScreen('user/' + payload.member.userId);
451452
break;
452453
case 'view_room':
453454
// Takes either a room ID or room alias: if switching to a room the client is already
@@ -1203,21 +1204,44 @@ module.exports = React.createClass({
12031204
} else if (screen.indexOf('user/') == 0) {
12041205
const userId = screen.substring(5);
12051206

1206-
if (params.action === 'chat') {
1207-
this._chatCreateOrReuse(userId);
1208-
return;
1209-
}
1207+
// Wait for the first sync so that `getRoom` gives us a room object if it's
1208+
// in the sync response
1209+
const waitFor = this.firstSyncPromise ?
1210+
this.firstSyncPromise.promise : Promise.resolve();
1211+
waitFor.then(() => {
1212+
if (params.action === 'chat') {
1213+
this._chatCreateOrReuse(userId);
1214+
return;
1215+
}
1216+
1217+
// Get the member object for the current room, if a current room is set or
1218+
// we have a last_room in localStorage. The user might not be a member of
1219+
// this room (in which case member will be falsey).
1220+
let member;
1221+
const roomId = this.state.currentRoomId || localStorage.getItem('mx_last_room_id');
1222+
if (roomId) {
1223+
const room = MatrixClientPeg.get().getRoom(roomId);
1224+
if (room) {
1225+
member = room.getMember(userId);
1226+
}
1227+
}
12101228

1211-
this.setState({ viewUserId: userId });
1212-
this._setPage(PageTypes.UserView);
1213-
this.notifyNewScreen('user/' + userId);
1214-
const member = new Matrix.RoomMember(null, userId);
1215-
if (member) {
1229+
if (member) {
1230+
// This user is a member of this room, so view the room
1231+
dis.dispatch({
1232+
action: 'view_room',
1233+
room_id: roomId,
1234+
});
1235+
} else {
1236+
// This user is not a member of this room, show the user view
1237+
member = new Matrix.RoomMember(null, userId);
1238+
this._setPage(PageTypes.UserView);
1239+
}
12161240
dis.dispatch({
12171241
action: 'view_user',
12181242
member: member,
12191243
});
1220-
}
1244+
});
12211245
} else if (screen.indexOf('group/') == 0) {
12221246
const groupId = screen.substring(6);
12231247

0 commit comments

Comments
 (0)