diff --git a/src/stores/BreadcrumbsStore.ts b/src/stores/BreadcrumbsStore.ts index cb1018326c..bc5c342c73 100644 --- a/src/stores/BreadcrumbsStore.ts +++ b/src/stores/BreadcrumbsStore.ts @@ -26,6 +26,7 @@ import { SettingLevel } from "../settings/SettingLevel"; import { Action } from "../dispatcher/actions"; import { SettingUpdatedPayload } from "../dispatcher/payloads/SettingUpdatedPayload"; import { ViewRoomPayload } from "../dispatcher/payloads/ViewRoomPayload"; +import { JoinRoomPayload } from "../dispatcher/payloads/JoinRoomPayload"; const MAX_ROOMS = 20; // arbitrary const AUTOJOIN_WAIT_THRESHOLD_MS = 90000; // 90s, the time we wait for an autojoined room to show up @@ -65,9 +66,8 @@ export class BreadcrumbsStore extends AsyncStoreWithClient { return this.matrixClient?.getVisibleRooms().length >= 20; } - protected async onAction(payload: SettingUpdatedPayload | ViewRoomPayload) { + protected async onAction(payload: SettingUpdatedPayload | ViewRoomPayload | JoinRoomPayload) { if (!this.matrixClient) return; - if (payload.action === Action.SettingUpdated) { if (payload.settingName === 'breadcrumb_rooms') { await this.updateRooms(); @@ -84,8 +84,12 @@ export class BreadcrumbsStore extends AsyncStoreWithClient { } else { // The tests might not result in a valid room object. const room = this.matrixClient.getRoom(payload.room_id); - if (room) await this.appendRoom(room); + const membership = room?.getMyMembership(); + if (room && membership==="join") await this.appendRoom(room); } + } else if (payload.action === Action.JoinRoom) { + const room = this.matrixClient.getRoom(payload.roomId); + if (room) await this.appendRoom(room); } }