Replace MatrixClient.isRoomEncrypted by MatrixClient.CryptoApi.isEncryptionEnabledInRoom in MemberListStore.tsx

This commit is contained in:
Florian Duros 2024-11-14 17:59:18 +01:00
parent 6533a6b642
commit f8c5eac8a9
No known key found for this signature in database
GPG Key ID: A5BBB4041B493F15
2 changed files with 4 additions and 5 deletions

View File

@ -70,7 +70,7 @@ export class MemberListStore {
return []; return [];
} }
if (!this.isLazyLoadingEnabled(roomId) || this.loadedRooms.has(roomId)) { if (!(await this.isLazyLoadingEnabled(roomId)) || this.loadedRooms.has(roomId)) {
// nice and easy, we must already have all the members so just return them. // nice and easy, we must already have all the members so just return them.
return this.loadMembersInRoom(room); return this.loadMembersInRoom(room);
} }
@ -121,10 +121,10 @@ export class MemberListStore {
* @param roomId The room to check if lazy loading is enabled * @param roomId The room to check if lazy loading is enabled
* @returns True if enabled * @returns True if enabled
*/ */
private isLazyLoadingEnabled(roomId: string): boolean { private async isLazyLoadingEnabled(roomId: string): Promise<boolean> {
if (SettingsStore.getValue("feature_sliding_sync")) { if (SettingsStore.getValue("feature_sliding_sync")) {
// only unencrypted rooms use lazy loading // only unencrypted rooms use lazy loading
return !this.stores.client!.isRoomEncrypted(roomId); return !(await this.stores.client?.getCrypto()?.isEncryptionEnabledInRoom(roomId));
} }
return this.stores.client!.hasLazyLoadMembersEnabled(); return this.stores.client!.hasLazyLoadMembersEnabled();
} }

View File

@ -189,8 +189,7 @@ describe("MemberListStore", () => {
}); });
it("does not use lazy loading on encrypted rooms", async () => { it("does not use lazy loading on encrypted rooms", async () => {
client.isRoomEncrypted = jest.fn(); jest.spyOn(client.getCrypto()!, "isEncryptionEnabledInRoom").mockResolvedValue(true);
mocked(client.isRoomEncrypted).mockReturnValue(true);
const { joined } = await store.loadMemberList(roomId); const { joined } = await store.loadMemberList(roomId);
expect(joined).toEqual([room.getMember(alice)]); expect(joined).toEqual([room.getMember(alice)]);