Skip to content

Commit 97ef1dc

Browse files
authored
Remove deprecated calls of MatrixClient (#4563)
1 parent 125e45c commit 97ef1dc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/models/relations.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { RelationType } from "../@types/event.ts";
2020
import { TypedEventEmitter } from "./typed-event-emitter.ts";
2121
import { MatrixClient } from "../client.ts";
2222
import { Room } from "./room.ts";
23+
import { CryptoBackend } from "../common-crypto/CryptoBackend.ts";
2324

2425
export enum RelationsEvent {
2526
Add = "Relations.add",
@@ -323,8 +324,9 @@ export class Relations extends TypedEventEmitter<RelationsEvent, EventHandlerMap
323324
return event;
324325
}, null);
325326

326-
if (lastReplacement?.shouldAttemptDecryption() && this.client.isCryptoEnabled()) {
327-
await lastReplacement.attemptDecryption(this.client.crypto!);
327+
if (lastReplacement?.shouldAttemptDecryption() && this.client.getCrypto()) {
328+
// Dirty but we are expecting to pass the cryptoBackend which is not accessible here
329+
await lastReplacement.attemptDecryption(this.client.getCrypto() as CryptoBackend);
328330
} else if (lastReplacement?.isBeingDecrypted()) {
329331
await lastReplacement.getDecryptionPromise();
330332
}

src/models/room.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
545545
* @returns Signals when all events have been decrypted
546546
*/
547547
public async decryptCriticalEvents(): Promise<void> {
548-
if (!this.client.isCryptoEnabled()) return;
548+
if (!this.client.getCrypto()) return;
549549

550550
const readReceiptEventId = this.getEventReadUpTo(this.client.getUserId()!, true);
551551
const events = this.getLiveTimeline().getEvents();
@@ -567,7 +567,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
567567
* @returns Signals when all events have been decrypted
568568
*/
569569
public async decryptAllEvents(): Promise<void> {
570-
if (!this.client.isCryptoEnabled()) return;
570+
if (!this.client.getCrypto()) return;
571571

572572
const decryptionPromises = this.getUnfilteredTimelineSet()
573573
.getLiveTimeline()

0 commit comments

Comments
 (0)