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

Commit fbc1779

Browse files
authored
Merge pull request #2611 from matrix-org/jryans/welcome-page-cleanup
Welcome page cleanup
2 parents e7e322d + 44e34d9 commit fbc1779

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

src/components/structures/MatrixChat.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,8 @@ export default React.createClass({
574574
const UserSettingsDialog = sdk.getComponent("dialogs.UserSettingsDialog");
575575
Modal.createTrackedDialog('User settings', '', UserSettingsDialog, {}, 'mx_SettingsDialog');
576576

577-
// View the home page if we need something to look at
578-
if (!this.state.currentGroupId && !this.state.currentRoomId) {
579-
this._setPage(PageTypes.HomePage);
580-
this.notifyNewScreen('home');
581-
}
577+
// View the welcome or home page if we need something to look at
578+
this._viewSomethingBehindModal();
582579
break;
583580
}
584581
case 'view_create_room':
@@ -595,11 +592,8 @@ export default React.createClass({
595592
config: this.props.config,
596593
}, 'mx_RoomDirectory_dialogWrapper');
597594

598-
// View the home page if we need something to look at
599-
if (!this.state.currentGroupId && !this.state.currentRoomId) {
600-
this._setPage(PageTypes.HomePage);
601-
this.notifyNewScreen('home');
602-
}
595+
// View the welcome or home page if we need something to look at
596+
this._viewSomethingBehindModal();
603597
}
604598
break;
605599
case 'view_my_groups':
@@ -825,6 +819,7 @@ export default React.createClass({
825819
this.focusComposer = true;
826820

827821
const newState = {
822+
view: VIEWS.LOGGED_IN,
828823
currentRoomId: roomInfo.room_id || null,
829824
page_type: PageTypes.RoomView,
830825
thirdPartyInvite: roomInfo.third_party_invite,
@@ -887,6 +882,16 @@ export default React.createClass({
887882
this.notifyNewScreen('group/' + groupId);
888883
},
889884

885+
_viewSomethingBehindModal() {
886+
if (this.state.view !== VIEWS.LOGGED_IN) {
887+
this._viewWelcome();
888+
return;
889+
}
890+
if (!this.state.currentGroupId && !this.state.currentRoomId) {
891+
this._viewHome();
892+
}
893+
},
894+
890895
_viewWelcome() {
891896
this.setStateForNewView({
892897
view: VIEWS.WELCOME,
@@ -1552,11 +1557,7 @@ export default React.createClass({
15521557
payload.room_id = roomString;
15531558
}
15541559

1555-
// we can't view a room unless we're logged in
1556-
// (a guest account is fine)
1557-
if (this.state.view === VIEWS.LOGGED_IN) {
1558-
dis.dispatch(payload);
1559-
}
1560+
dis.dispatch(payload);
15601561
} else if (screen.indexOf('user/') == 0) {
15611562
const userId = screen.substring(5);
15621563

src/components/structures/RoomDirectory.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ module.exports = React.createClass({
7878
this.protocols = null;
7979

8080
this.setState({protocolsLoading: true});
81+
if (!MatrixClientPeg.get()) {
82+
// We may not have a client yet when invoked from welcome page
83+
this.setState({protocolsLoading: false});
84+
return;
85+
}
8186
MatrixClientPeg.get().getThirdpartyProtocols().done((response) => {
8287
this.protocols = response;
8388
this.setState({protocolsLoading: false});

src/components/structures/RoomView.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ module.exports = React.createClass({
283283
}
284284
},
285285

286+
_getRoomId() {
287+
// According to `_onRoomViewStoreUpdate`, `state.roomId` can be null
288+
// if we have a room alias we haven't resolved yet. To work around this,
289+
// first we'll try the room object if it's there, and then fallback to
290+
// the bare room ID. (We may want to update `state.roomId` after
291+
// resolving aliases, so we could always trust it.)
292+
return this.state.room ? this.state.room.roomId : this.state.roomId;
293+
},
294+
286295
_onWidgetEchoStoreUpdate: function() {
287296
this.setState({
288297
showApps: this._shouldShowApps(this.state.room),
@@ -877,13 +886,12 @@ module.exports = React.createClass({
877886
// If the user is a ROU, allow them to transition to a PWLU
878887
if (cli && cli.isGuest()) {
879888
// Join this room once the user has registered and logged in
880-
const signUrl = this.props.thirdPartyInvite ?
881-
this.props.thirdPartyInvite.inviteSignUrl : undefined;
889+
// (If we failed to peek, we may not have a valid room object.)
882890
dis.dispatch({
883891
action: 'do_after_sync_prepared',
884892
deferred_action: {
885893
action: 'view_room',
886-
room_id: this.state.room.roomId,
894+
room_id: this._getRoomId(),
887895
},
888896
});
889897

0 commit comments

Comments
 (0)