diff --git a/src/stores/AsyncStoreWithClient.ts b/src/stores/AsyncStoreWithClient.ts index 4accef6f77..1ed7c6a547 100644 --- a/src/stores/AsyncStoreWithClient.ts +++ b/src/stores/AsyncStoreWithClient.ts @@ -48,7 +48,10 @@ export abstract class AsyncStoreWithClient extends AsyncStore< await this.onAction(payload); 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')) { return; } diff --git a/src/stores/BreadcrumbsStore.ts b/src/stores/BreadcrumbsStore.ts index 34affbe746..ea29cb9dfc 100644 --- a/src/stores/BreadcrumbsStore.ts +++ b/src/stores/BreadcrumbsStore.ts @@ -55,7 +55,7 @@ export class BreadcrumbsStore extends AsyncStoreWithClient { } private get meetsRoomRequirement(): boolean { - return this.matrixClient.getVisibleRooms().length >= 20; + return this.matrixClient && this.matrixClient.getVisibleRooms().length >= 20; } protected async onAction(payload: ActionPayload) {