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 { roomId } = this.props.member;
if (roomId) {
const isRoomEncrypted = cli.isRoomEncrypted(roomId);
const isRoomEncrypted = Boolean(await cli.getCrypto()?.isEncryptionEnabledInRoom(roomId));
this.setState({
isRoomEncrypted,
});

View File

@ -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(),
});

View File

@ -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()!);
});