Fix failure to request persistent storage perms (#31299)
* Move call to `tryPersistStorage` to `OnLoggedIn` handler I think this needs to happen whether or not we are in the middle of a login flow. Fixes: https://github.com/element-hq/element-web/issues/31298 * Inline `MatrixChat.onLoggedIn` It's now a one-liner, and its semantics are very confusing. * Factor out `MatrixChat.onLoggedIn` Now that we've got rid of the confusing `onLoggedIn` method, we can factor out a method which *actually* handles `OnLoggedIn` actions.
This commit is contained in:
committed by
GitHub
parent
32cce82790
commit
eeb2c0f690
@@ -395,8 +395,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform actions that are specific to a user that has just logged in (compare {@link onLoggedIn}, which, despite
|
* Perform actions that are specific to a user that has just logged in.
|
||||||
* its name, is called when an already-logged-in client is restored at session startup).
|
|
||||||
*
|
*
|
||||||
* Called when:
|
* Called when:
|
||||||
*
|
*
|
||||||
@@ -404,7 +403,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
* - The {@link Login} or {@link Register} components notify us that we successfully completed a non-OIDC login or
|
* - The {@link Login} or {@link Register} components notify us that we successfully completed a non-OIDC login or
|
||||||
* registration.
|
* registration.
|
||||||
*
|
*
|
||||||
* In both cases, {@link Action.OnLoggedIn} will already have been emitted, but the call to {@link onLoggedIn} will
|
* In both cases, {@link Action.OnLoggedIn} will already have been emitted, but the call to {@link onShowPostLoginScreen} will
|
||||||
* have been suppressed (by either {@link tokenLogin} being set, or the view being set to {@link Views.LOGIN} or
|
* have been suppressed (by either {@link tokenLogin} being set, or the view being set to {@link Views.LOGIN} or
|
||||||
* {@link Views.REGISTER}).
|
* {@link Views.REGISTER}).
|
||||||
*
|
*
|
||||||
@@ -418,7 +417,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
const cli = MatrixClientPeg.safeGet();
|
const cli = MatrixClientPeg.safeGet();
|
||||||
const cryptoEnabled = Boolean(cli.getCrypto());
|
const cryptoEnabled = Boolean(cli.getCrypto());
|
||||||
if (!cryptoEnabled) {
|
if (!cryptoEnabled) {
|
||||||
this.onLoggedIn();
|
this.onShowPostLoginScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
const promisesList: Promise<any>[] = [this.firstSyncPromise.promise];
|
const promisesList: Promise<any>[] = [this.firstSyncPromise.promise];
|
||||||
@@ -451,7 +450,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
|
|
||||||
const cryptoExtension = ModuleRunner.instance.extensions.cryptoSetup;
|
const cryptoExtension = ModuleRunner.instance.extensions.cryptoSetup;
|
||||||
if (cryptoExtension.SHOW_ENCRYPTION_SETUP_UI == false) {
|
if (cryptoExtension.SHOW_ENCRYPTION_SETUP_UI == false) {
|
||||||
this.onLoggedIn();
|
this.onShowPostLoginScreen();
|
||||||
} else {
|
} else {
|
||||||
this.setStateForNewView({ view: Views.COMPLETE_SECURITY });
|
this.setStateForNewView({ view: Views.COMPLETE_SECURITY });
|
||||||
}
|
}
|
||||||
@@ -463,7 +462,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
);
|
);
|
||||||
this.setStateForNewView({ view: Views.E2E_SETUP });
|
this.setStateForNewView({ view: Views.E2E_SETUP });
|
||||||
} else {
|
} else {
|
||||||
this.onLoggedIn();
|
this.onShowPostLoginScreen();
|
||||||
}
|
}
|
||||||
this.setState({ pendingInitialSync: false });
|
this.setState({ pendingInitialSync: false });
|
||||||
}
|
}
|
||||||
@@ -868,18 +867,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
Modal.createDialog(DialPadModal, {}, "mx_Dialog_dialPadWrapper");
|
Modal.createDialog(DialPadModal, {}, "mx_Dialog_dialPadWrapper");
|
||||||
break;
|
break;
|
||||||
case Action.OnLoggedIn:
|
case Action.OnLoggedIn:
|
||||||
this.stores.client = MatrixClientPeg.safeGet();
|
this.onLoggedIn();
|
||||||
if (
|
|
||||||
// Skip this handling for token login as that always calls onLoggedIn itself
|
|
||||||
!this.tokenLogin &&
|
|
||||||
!Lifecycle.isSoftLogout() &&
|
|
||||||
this.state.view !== Views.LOGIN &&
|
|
||||||
this.state.view !== Views.REGISTER &&
|
|
||||||
this.state.view !== Views.COMPLETE_SECURITY &&
|
|
||||||
this.state.view !== Views.E2E_SETUP
|
|
||||||
) {
|
|
||||||
this.onLoggedIn();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Action.ClientNotViable:
|
case Action.ClientNotViable:
|
||||||
this.onSoftLogout();
|
this.onSoftLogout();
|
||||||
@@ -1392,28 +1380,12 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a new logged in session has started.
|
* Show the first screen after the application is successfully loaded in a logged-in state.
|
||||||
*
|
*
|
||||||
* Called:
|
* Called:
|
||||||
*
|
*
|
||||||
* - on {@link Action.OnLoggedIn}, but only when we don't expect a separate call to {@link postLoginSetup}.
|
* - on {@link Action.OnLoggedIn}, but only when we don't expect a separate call to {@link postLoginSetup}.
|
||||||
* - from {@link postLoginSetup}, when we don't have crypto setup tasks to perform after the login.
|
* - from {@link postLoginSetup}, when we don't have crypto setup tasks to perform after the login.
|
||||||
*
|
|
||||||
* It's never actually called if we have crypto setup tasks to perform after login (which we normally do, unless
|
|
||||||
* crypto is disabled.) XXX: is this a bug or a feature?
|
|
||||||
*/
|
|
||||||
private async onLoggedIn(): Promise<void> {
|
|
||||||
StorageManager.tryPersistStorage();
|
|
||||||
|
|
||||||
await this.onShowPostLoginScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the first screen after the application is successfully loaded in a logged-in state.
|
|
||||||
*
|
|
||||||
* Called:
|
|
||||||
*
|
|
||||||
* - by {@link onLoggedIn}
|
|
||||||
* - by {@link onCompleteSecurityE2eSetupFinished}
|
* - by {@link onCompleteSecurityE2eSetupFinished}
|
||||||
*
|
*
|
||||||
* In other words, whenever we think we have completed the login and E2E setup tasks.
|
* In other words, whenever we think we have completed the login and E2E setup tasks.
|
||||||
@@ -1527,6 +1499,28 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an {@link Action.OnLoggedIn} action (i.e, we now have a client with working credentials).
|
||||||
|
*/
|
||||||
|
private onLoggedIn(): void {
|
||||||
|
this.stores.client = MatrixClientPeg.safeGet();
|
||||||
|
StorageManager.tryPersistStorage();
|
||||||
|
|
||||||
|
// If we're in the middle of a login/registration, we wait for it to complete before transitioning to the logged
|
||||||
|
// in view the login flow will call `postLoginSetup` when it's done, which will arrange for `onShowPostLoginScreen`
|
||||||
|
// to be called.
|
||||||
|
if (
|
||||||
|
!this.tokenLogin &&
|
||||||
|
!Lifecycle.isSoftLogout() &&
|
||||||
|
this.state.view !== Views.LOGIN &&
|
||||||
|
this.state.view !== Views.REGISTER &&
|
||||||
|
this.state.view !== Views.COMPLETE_SECURITY &&
|
||||||
|
this.state.view !== Views.E2E_SETUP
|
||||||
|
) {
|
||||||
|
this.onShowPostLoginScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the session is logged out
|
* Called when the session is logged out
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user