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

This commit is contained in:
Florian Duros 2024-11-20 11:02:08 +01:00
parent 92405c39fc
commit f227ac8205
No known key found for this signature in database
GPG Key ID: A5BBB4041B493F15
3 changed files with 5 additions and 3 deletions

View File

@ -49,12 +49,12 @@ export default class MemberTile extends React.Component<IProps, IState> {
}; };
} }
public componentDidMount(): void { public async componentDidMount(): Promise<void> {
const cli = MatrixClientPeg.safeGet(); const cli = MatrixClientPeg.safeGet();
const { roomId } = this.props.member; const { roomId } = this.props.member;
if (roomId) { if (roomId) {
const isRoomEncrypted = cli.isRoomEncrypted(roomId); const isRoomEncrypted = Boolean(await cli.getCrypto()?.isEncryptionEnabledInRoom(roomId));
this.setState({ this.setState({
isRoomEncrypted, isRoomEncrypted,
}); });

View File

@ -31,6 +31,7 @@ import {
filterConsole, filterConsole,
flushPromises, flushPromises,
getMockClientWithEventEmitter, getMockClientWithEventEmitter,
mockClientMethodsCrypto,
mockClientMethodsRooms, mockClientMethodsRooms,
mockClientMethodsUser, mockClientMethodsUser,
} from "../../../../test-utils"; } from "../../../../test-utils";
@ -361,6 +362,7 @@ describe("MemberList", () => {
client = getMockClientWithEventEmitter({ client = getMockClientWithEventEmitter({
...mockClientMethodsUser(), ...mockClientMethodsUser(),
...mockClientMethodsRooms(), ...mockClientMethodsRooms(),
...mockClientMethodsCrypto(),
getRoom: jest.fn(), getRoom: jest.fn(),
hasLazyLoadMembersEnabled: jest.fn(), hasLazyLoadMembersEnabled: jest.fn(),
}); });

View File

@ -22,7 +22,7 @@ describe("MemberTile", () => {
beforeEach(() => { beforeEach(() => {
matrixClient = TestUtils.stubClient(); matrixClient = TestUtils.stubClient();
mocked(matrixClient.isRoomEncrypted).mockReturnValue(true); jest.spyOn(matrixClient.getCrypto()!, "isEncryptionEnabledInRoom").mockResolvedValue(true);
member = new RoomMember("roomId", matrixClient.getUserId()!); member = new RoomMember("roomId", matrixClient.getUserId()!);
}); });