Skip to content

Commit ecd05e9

Browse files
committed
MatrixChat: add a load of logging for view transitions
This stuff was essentially impossible to follow and debug. I think a load of logging will help.
1 parent 1d1f0e5 commit ecd05e9

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/components/structures/MatrixChat.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
473473
| (Pick<IState, K> | IState | null),
474474
callback?: () => void,
475475
): void {
476+
if (state && "view" in state) {
477+
logger.debug(`MatrixChat: Queuing change of view from ${Views[this.state.view]} to ${Views[state.view]}`);
478+
}
476479
if (this.shouldTrackPageChange(this.state, { ...this.state, ...state })) {
477480
this.startPageChangeTimer();
478481
}
@@ -648,6 +651,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
648651
private onAction = (payload: ActionPayload): void => {
649652
// once the session lock has been stolen, don't try to do anything.
650653
if (this.state.view === Views.LOCK_STOLEN) {
654+
logger.warn(`Ignoring action ${payload.action} as session lock has been stolen`);
651655
return;
652656
}
653657

@@ -1391,10 +1395,13 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
13911395
* In other words, whenever we think we have completed the login and E2E setup tasks.
13921396
*/
13931397
private async onShowPostLoginScreen(): Promise<void> {
1398+
logger.debug("onShowPostLoginScreen: Transitioning to logged in view.");
1399+
13941400
this.setStateForNewView({ view: Views.LOGGED_IN });
13951401
// If a specific screen is set to be shown after login, show that above
13961402
// all else, as it probably means the user clicked on something already.
13971403
if (this.screenAfterLogin?.screen) {
1404+
logger.debug(`onShowPostLoginScreen: showing screen ${this.screenAfterLogin.screen}`);
13981405
this.showScreen(this.screenAfterLogin.screen, this.screenAfterLogin.params);
13991406
this.screenAfterLogin = undefined;
14001407
} else if (MatrixClientPeg.currentUserIsJustRegistered()) {
@@ -1403,6 +1410,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
14031410
if (ThreepidInviteStore.instance.pickBestInvite()) {
14041411
// The user has a 3pid invite pending - show them that
14051412
const threepidInvite = ThreepidInviteStore.instance.pickBestInvite();
1413+
logger.debug(`onShowPostLoginScreen: showing room ${threepidInvite.roomId} after registration`);
14061414

14071415
// HACK: This is a pretty brutal way of threading the invite back through
14081416
// our systems, but it's the safest we have for now.
@@ -1411,9 +1419,11 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
14111419
} else {
14121420
// The user has just logged in after registering,
14131421
// so show the homepage.
1422+
logger.debug("onShowPostLoginScreen: Showing home page after registration");
14141423
dis.dispatch<ViewHomePagePayload>({ action: Action.ViewHomePage, justRegistered: true });
14151424
}
14161425
} else if (!(await this.shouldForceVerification())) {
1426+
logger.debug("onShowPostLoginScreen: showScreenAfterLogin");
14171427
this.showScreenAfterLogin();
14181428
}
14191429

@@ -1477,15 +1487,19 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
14771487
// If screenAfterLogin is set, use that, then null it so that a second login will
14781488
// result in view_home_page, _user_settings or _room_directory
14791489
if (this.screenAfterLogin && this.screenAfterLogin.screen) {
1490+
logger.debug(`showScreenAfterLogin: showing screen ${this.screenAfterLogin.screen}`);
14801491
this.showScreen(this.screenAfterLogin.screen, this.screenAfterLogin.params);
14811492
this.screenAfterLogin = undefined;
14821493
} else if (localStorage && localStorage.getItem("mx_last_room_id")) {
14831494
// Before defaulting to directory, show the last viewed room
1495+
logger.debug(`showScreenAfterLogin: showing last room`);
14841496
this.viewLastRoom();
14851497
} else {
14861498
if (MatrixClientPeg.safeGet().isGuest()) {
1499+
logger.debug(`showScreenAfterLogin: showing guest welcome page`);
14871500
dis.dispatch({ action: "view_welcome_page" });
14881501
} else {
1502+
logger.debug(`showScreenAfterLogin: showing home page`);
14891503
dis.dispatch({ action: Action.ViewHomePage });
14901504
}
14911505
}
@@ -1778,10 +1792,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
17781792
}
17791793

17801794
public showScreen(screen: string, params?: { [key: string]: any }): void {
1795+
logger.debug(`showScreen ${screen}`);
1796+
17811797
const cli = MatrixClientPeg.get();
17821798
const isLoggedOutOrGuest = !cli || cli.isGuest();
17831799
if (!isLoggedOutOrGuest && AUTH_SCREENS.includes(screen)) {
17841800
// user is logged in and landing on an auth page which will uproot their session, redirect them home instead
1801+
logger.info(
1802+
`showScreen: suppressing change to AuthScreen ${screen} for logged-in user, and going to home screen instead`,
1803+
);
17851804
dis.dispatch({ action: Action.ViewHomePage });
17861805
return;
17871806
}

0 commit comments

Comments
 (0)