From 5bd41209200798e93594776a29d6c789098f42e9 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Fri, 7 May 2021 12:58:37 +0100 Subject: [PATCH] Decrypt breadcrumb events for better UX --- src/stores/BreadcrumbsStore.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/stores/BreadcrumbsStore.ts b/src/stores/BreadcrumbsStore.ts index 393f4f27a1..5c49fef148 100644 --- a/src/stores/BreadcrumbsStore.ts +++ b/src/stores/BreadcrumbsStore.ts @@ -22,6 +22,7 @@ import defaultDispatcher from "../dispatcher/dispatcher"; import { arrayHasDiff } from "../utils/arrays"; import { isNullOrUndefined } from "matrix-js-sdk/src/utils"; import { SettingLevel } from "../settings/SettingLevel"; +import {MatrixClientPeg} from '../MatrixClientPeg'; const MAX_ROOMS = 20; // arbitrary const AUTOJOIN_WAIT_THRESHOLD_MS = 90000; // 90s, the time we wait for an autojoined room to show up @@ -87,6 +88,23 @@ export class BreadcrumbsStore extends AsyncStoreWithClient { this.matrixClient.on("Room.myMembership", this.onMyMembership); this.matrixClient.on("Room", this.onRoom); + + const client = MatrixClientPeg.get(); + const breadcrumbs = client.store.getAccountData("im.vector.setting.breadcrumbs"); + const breadcrumbsRooms: string[] = breadcrumbs?.getContent().recent_rooms || []; + + breadcrumbsRooms.map(async roomId => { + const room = client.getRoom(roomId); + if (room) { + const [cryptoEvent] = room.currentState.getStateEvents("m.room.encryption"); + if (cryptoEvent) { + if (!client.isRoomEncrypted(roomId)) { + await client._crypto.onCryptoEvent(cryptoEvent); + } + return room?.decryptAllEvents(); + } + } + }); } protected async onNotReady() {