Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a37f415

Browse files
committed
Do not eagerly decrypt breadcrumb rooms
1 parent 712bdba commit a37f415

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

src/stores/BreadcrumbsStore.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ limitations under the License.
1616

1717
import SettingsStore from "../settings/SettingsStore";
1818
import { Room } from "matrix-js-sdk/src/models/room";
19-
import { EventType } from "matrix-js-sdk/src/@types/event";
2019
import { ActionPayload } from "../dispatcher/payloads";
2120
import { AsyncStoreWithClient } from "./AsyncStoreWithClient";
2221
import defaultDispatcher from "../dispatcher/dispatcher";
2322
import { arrayHasDiff } from "../utils/arrays";
2423
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
2524
import { SettingLevel } from "../settings/SettingLevel";
26-
import { MatrixClientPeg } from '../MatrixClientPeg';
2725

2826
const MAX_ROOMS = 20; // arbitrary
2927
const AUTOJOIN_WAIT_THRESHOLD_MS = 90000; // 90s, the time we wait for an autojoined room to show up
@@ -61,30 +59,6 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
6159
return this.matrixClient && this.matrixClient.getVisibleRooms().length >= 20;
6260
}
6361

64-
componentDidUpdate(prevProps, prevState) {
65-
const prevRoomCount = (prevState.rooms?.length || 0);
66-
const currentRoomCount = (this.state.rooms?.length || 0)
67-
68-
// Only decrypting the breadcrumb rooms events on app initialisation
69-
// when room count transitions from 0 to the number of rooms it contains
70-
if (prevRoomCount === 0 && currentRoomCount > prevRoomCount) {
71-
const client = MatrixClientPeg.get();
72-
// Rooms in the breadcrumb have a good chance to be interacted with
73-
// again by a user. Decrypting the messages ahead of time will help
74-
// reduce content shift on first render
75-
this.state.rooms?.forEach(async room => {
76-
const [cryptoEvent] = room.currentState.getStateEvents(EventType.RoomEncryption);
77-
if (cryptoEvent) {
78-
if (!client.isRoomEncrypted(room.roomId)) {
79-
// XXX: Private member access
80-
await client._crypto.onCryptoEvent(cryptoEvent);
81-
}
82-
room?.decryptAllEvents();
83-
}
84-
});
85-
}
86-
}
87-
8862
protected async onAction(payload: ActionPayload) {
8963
if (!this.matrixClient) return;
9064

0 commit comments

Comments
 (0)