Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove deprecated calls of MatrixClient
Browse files Browse the repository at this point in the history
florianduros committed Nov 28, 2024
1 parent 3781b6e commit a56c1e7
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/models/relations.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import { RelationType } from "../@types/event.ts";
import { TypedEventEmitter } from "./typed-event-emitter.ts";
import { MatrixClient } from "../client.ts";
import { Room } from "./room.ts";
import { CryptoBackend } from "../common-crypto/CryptoBackend.ts";

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

if (lastReplacement?.shouldAttemptDecryption() && this.client.isCryptoEnabled()) {
await lastReplacement.attemptDecryption(this.client.crypto!);
if (lastReplacement?.shouldAttemptDecryption() && this.client.getCrypto()) {
// Dirty but we are expecting to pass the cryptoBackend which is not accessible here
await lastReplacement.attemptDecryption(this.client.getCrypto() as CryptoBackend);
} else if (lastReplacement?.isBeingDecrypted()) {
await lastReplacement.getDecryptionPromise();
}
4 changes: 2 additions & 2 deletions src/models/room.ts
Original file line number Diff line number Diff line change
@@ -545,7 +545,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
* @returns Signals when all events have been decrypted
*/
public async decryptCriticalEvents(): Promise<void> {
if (!this.client.isCryptoEnabled()) return;
if (!this.client.getCrypto()) return;

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

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

0 comments on commit a56c1e7

Please sign in to comment.