Remove unused packages and fix invariant violation on AsyncStore onNotReady (#9404)

* Remove traces of browser-request & mocha

* Remove unused matrix-react-test-utils

* Fix dispatcher invariant violation

* Add null-guard

* Improve types

* Fix null-guard

* Fix issue with authed users going directly to /#/login
This commit is contained in:
Michael Telatynski 2022-10-13 09:22:32 +01:00 committed by GitHub
parent 28bd58e551
commit 1800cb8c71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 57 deletions

View file

@ -337,14 +337,19 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
// the old creds, but rather go straight to the relevant page
const firstScreen = this.screenAfterLogin ? this.screenAfterLogin.screen : null;
if (firstScreen === 'login' ||
firstScreen === 'register' ||
firstScreen === 'forgot_password') {
this.showScreenAfterLogin();
return;
const restoreSuccess = await this.loadSession();
if (restoreSuccess) {
return true;
}
return this.loadSession();
if (firstScreen === 'login' ||
firstScreen === 'register' ||
firstScreen === 'forgot_password'
) {
this.showScreenAfterLogin();
}
return false;
});
}
@ -470,7 +475,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
return { serverConfig: props };
}
private loadSession() {
private loadSession(): Promise<boolean> {
// the extra Promise.resolve() ensures that synchronous exceptions hit the same codepath as
// asynchronous ones.
return Promise.resolve().then(() => {
@ -490,6 +495,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
dis.dispatch({ action: "view_welcome_page" });
}
}
return loadedSession;
});
// Note we don't catch errors from this: we catch everything within
// loadSession as there's logic there to ask the user if they want