From d717d06ce587053ef074345920adde87d93df6c5 Mon Sep 17 00:00:00 2001 From: Sinharitik589 <67551927+Sinharitik589@users.noreply.github.com> Date: Tue, 17 May 2022 19:38:36 +0530 Subject: [PATCH] Prevent invites from showing up in breadcrumbs (#8344) --- src/stores/BreadcrumbsStore.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); } }