Merge pull request #5068 from matrix-org/dbkr/fix_soft_logout_crash

Fix crash on logging in again after soft logout
This commit is contained in:
David Baker 2020-07-30 20:02:42 +01:00 committed by GitHub
commit e810a31fe3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -35,11 +35,13 @@ export abstract class AsyncStoreWithClient<T extends Object> extends AsyncStore<
await this.onAction(payload); await this.onAction(payload);
if (payload.action === 'MatrixActions.sync') { if (payload.action === 'MatrixActions.sync') {
// Filter out anything that isn't the first PREPARED sync. // Only set the client on the transition into the PREPARED state.
// Everything after this is unnecessary (we only need to know once we have a client)
// and we intentionally don't set the client before this point to avoid stores
// updating for every event emitted during the cached sync.
if (!(payload.prevState === 'PREPARED' && payload.state !== 'PREPARED')) { if (!(payload.prevState === 'PREPARED' && payload.state !== 'PREPARED')) {
return; return;
} }
this.matrixClient = payload.matrixClient; this.matrixClient = payload.matrixClient;
await this.onReady(); await this.onReady();
} else if (payload.action === 'on_client_not_viable' || payload.action === 'on_logged_out') { } else if (payload.action === 'on_client_not_viable' || payload.action === 'on_logged_out') {

View file

@ -55,7 +55,7 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
} }
private get meetsRoomRequirement(): boolean { private get meetsRoomRequirement(): boolean {
return this.matrixClient.getVisibleRooms().length >= 20; return this.matrixClient && this.matrixClient.getVisibleRooms().length >= 20;
} }
protected async onAction(payload: ActionPayload) { protected async onAction(payload: ActionPayload) {