mirror of https://github.com/vector-im/riot-web
Replace `MatrixClient.prepareToEncrypt` by `MatrixClient.getCrypto.prepareToEncrypt` (#146)
parent
503d9004d1
commit
bce02634f7
|
@ -367,7 +367,7 @@ export default class LegacyCallHandler extends EventEmitter {
|
||||||
// the mapped one: that's where we'll send the events.
|
// the mapped one: that's where we'll send the events.
|
||||||
const cli = MatrixClientPeg.safeGet();
|
const cli = MatrixClientPeg.safeGet();
|
||||||
const room = cli.getRoom(call.roomId);
|
const room = cli.getRoom(call.roomId);
|
||||||
if (room) cli.prepareToEncrypt(room);
|
if (room) cli.getCrypto()?.prepareToEncrypt(room);
|
||||||
};
|
};
|
||||||
|
|
||||||
public getCallById(callId: string): MatrixCall | null {
|
public getCallById(callId: string): MatrixCall | null {
|
||||||
|
|
|
@ -268,7 +268,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
||||||
if (this.props.mxClient.isCryptoEnabled() && this.props.mxClient.isRoomEncrypted(this.props.room.roomId)) {
|
if (this.props.mxClient.isCryptoEnabled() && this.props.mxClient.isRoomEncrypted(this.props.room.roomId)) {
|
||||||
this.prepareToEncrypt = throttle(
|
this.prepareToEncrypt = throttle(
|
||||||
() => {
|
() => {
|
||||||
this.props.mxClient.prepareToEncrypt(this.props.room);
|
this.props.mxClient.getCrypto()?.prepareToEncrypt(this.props.room);
|
||||||
},
|
},
|
||||||
60000,
|
60000,
|
||||||
{ leading: true, trailing: false },
|
{ leading: true, trailing: false },
|
||||||
|
|
|
@ -588,7 +588,6 @@ describe("LegacyCallHandler without third party protocols", () => {
|
||||||
jest.spyOn(MatrixClientPeg.safeGet(), "supportsVoip").mockReturnValue(true);
|
jest.spyOn(MatrixClientPeg.safeGet(), "supportsVoip").mockReturnValue(true);
|
||||||
|
|
||||||
MatrixClientPeg.safeGet().isFallbackICEServerAllowed = jest.fn();
|
MatrixClientPeg.safeGet().isFallbackICEServerAllowed = jest.fn();
|
||||||
MatrixClientPeg.safeGet().prepareToEncrypt = jest.fn();
|
|
||||||
|
|
||||||
MatrixClientPeg.safeGet().pushRules = {
|
MatrixClientPeg.safeGet().pushRules = {
|
||||||
global: {
|
global: {
|
||||||
|
|
|
@ -573,10 +573,9 @@ describe("<SendMessageComposer/>", () => {
|
||||||
const cli = stubClient();
|
const cli = stubClient();
|
||||||
cli.isCryptoEnabled = jest.fn().mockReturnValue(true);
|
cli.isCryptoEnabled = jest.fn().mockReturnValue(true);
|
||||||
cli.isRoomEncrypted = jest.fn().mockReturnValue(true);
|
cli.isRoomEncrypted = jest.fn().mockReturnValue(true);
|
||||||
cli.prepareToEncrypt = jest.fn();
|
|
||||||
const room = mkStubRoom("!roomId:server", "Room", cli);
|
const room = mkStubRoom("!roomId:server", "Room", cli);
|
||||||
|
|
||||||
expect(cli.prepareToEncrypt).not.toHaveBeenCalled();
|
expect(cli.getCrypto()!.prepareToEncrypt).not.toHaveBeenCalled();
|
||||||
|
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<MatrixClientContext.Provider value={cli}>
|
<MatrixClientContext.Provider value={cli}>
|
||||||
|
@ -588,9 +587,9 @@ describe("<SendMessageComposer/>", () => {
|
||||||
|
|
||||||
// Does not trigger on keydown as that'll cause false negatives for global shortcuts
|
// Does not trigger on keydown as that'll cause false negatives for global shortcuts
|
||||||
await userEvent.type(composer, "[ControlLeft>][KeyK][/ControlLeft]");
|
await userEvent.type(composer, "[ControlLeft>][KeyK][/ControlLeft]");
|
||||||
expect(cli.prepareToEncrypt).not.toHaveBeenCalled();
|
expect(cli.getCrypto()!.prepareToEncrypt).not.toHaveBeenCalled();
|
||||||
|
|
||||||
await userEvent.type(composer, "Hello");
|
await userEvent.type(composer, "Hello");
|
||||||
expect(cli.prepareToEncrypt).toHaveBeenCalled();
|
expect(cli.getCrypto()!.prepareToEncrypt).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -133,6 +133,7 @@ export function createTestClient(): MatrixClient {
|
||||||
isEncryptionEnabledInRoom: jest.fn(),
|
isEncryptionEnabledInRoom: jest.fn(),
|
||||||
getVerificationRequestsToDeviceInProgress: jest.fn().mockReturnValue([]),
|
getVerificationRequestsToDeviceInProgress: jest.fn().mockReturnValue([]),
|
||||||
setDeviceIsolationMode: jest.fn(),
|
setDeviceIsolationMode: jest.fn(),
|
||||||
|
prepareToEncrypt: jest.fn(),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getPushActionsForEvent: jest.fn(),
|
getPushActionsForEvent: jest.fn(),
|
||||||
|
|
Loading…
Reference in New Issue