From f227ac8205932489ae9b3ad94c7ffb3542821e5d Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Wed, 20 Nov 2024 11:02:08 +0100 Subject: [PATCH] Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `MemberTile.tsx` --- src/components/views/rooms/MemberTile.tsx | 4 ++-- test/unit-tests/components/views/rooms/MemberList-test.tsx | 2 ++ test/unit-tests/components/views/rooms/MemberTile-test.tsx | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/MemberTile.tsx b/src/components/views/rooms/MemberTile.tsx index acb2e5153b..9d2343e9d7 100644 --- a/src/components/views/rooms/MemberTile.tsx +++ b/src/components/views/rooms/MemberTile.tsx @@ -49,12 +49,12 @@ export default class MemberTile extends React.Component { }; } - public componentDidMount(): void { + public async componentDidMount(): Promise { const cli = MatrixClientPeg.safeGet(); const { roomId } = this.props.member; if (roomId) { - const isRoomEncrypted = cli.isRoomEncrypted(roomId); + const isRoomEncrypted = Boolean(await cli.getCrypto()?.isEncryptionEnabledInRoom(roomId)); this.setState({ isRoomEncrypted, }); diff --git a/test/unit-tests/components/views/rooms/MemberList-test.tsx b/test/unit-tests/components/views/rooms/MemberList-test.tsx index 34c37d2ba5..a190a33e09 100644 --- a/test/unit-tests/components/views/rooms/MemberList-test.tsx +++ b/test/unit-tests/components/views/rooms/MemberList-test.tsx @@ -31,6 +31,7 @@ import { filterConsole, flushPromises, getMockClientWithEventEmitter, + mockClientMethodsCrypto, mockClientMethodsRooms, mockClientMethodsUser, } from "../../../../test-utils"; @@ -361,6 +362,7 @@ describe("MemberList", () => { client = getMockClientWithEventEmitter({ ...mockClientMethodsUser(), ...mockClientMethodsRooms(), + ...mockClientMethodsCrypto(), getRoom: jest.fn(), hasLazyLoadMembersEnabled: jest.fn(), }); diff --git a/test/unit-tests/components/views/rooms/MemberTile-test.tsx b/test/unit-tests/components/views/rooms/MemberTile-test.tsx index cf829c2927..89d29d1137 100644 --- a/test/unit-tests/components/views/rooms/MemberTile-test.tsx +++ b/test/unit-tests/components/views/rooms/MemberTile-test.tsx @@ -22,7 +22,7 @@ describe("MemberTile", () => { beforeEach(() => { matrixClient = TestUtils.stubClient(); - mocked(matrixClient.isRoomEncrypted).mockReturnValue(true); + jest.spyOn(matrixClient.getCrypto()!, "isEncryptionEnabledInRoom").mockResolvedValue(true); member = new RoomMember("roomId", matrixClient.getUserId()!); });