add dispose to room encryption

This commit is contained in:
Bruno Windels 2020-09-18 13:08:18 +02:00
parent 6c46cc98de
commit ed913ca24b
4 changed files with 15 additions and 2 deletions

View file

@ -80,7 +80,7 @@ export class SessionLoadViewModel extends ViewModel {
async cancel() {
try {
if (this._sessionContainer) {
this._sessionContainer.stop();
this._sessionContainer.dispose();
if (this._deleteSessionOnCancel) {
await this._sessionContainer.deleteSession();
}

View file

@ -269,10 +269,13 @@ export class Session {
return this._sendScheduler.isStarted;
}
stop() {
dispose() {
this._olmWorker?.dispose();
this._sendScheduler.stop();
this._sessionBackup?.dispose();
for (const room of this._rooms.values()) {
room.dispose();
}
}
async start(lastVersionResponse) {

View file

@ -39,6 +39,7 @@ export class RoomEncryption {
this._storage = storage;
this._sessionBackup = sessionBackup;
this._notifyMissingMegolmSession = notifyMissingMegolmSession;
this._disposed = false;
}
async enableSessionBackup(sessionBackup) {
@ -322,6 +323,10 @@ export class RoomEncryption {
const txnId = makeTxnId();
await hsApi.sendToDevice(type, payload, txnId).response();
}
dispose() {
this._disposed = true;
}
}
/**

View file

@ -529,6 +529,11 @@ export class Room extends EventEmitter {
applyIsTrackingMembersChanges(changes) {
this._summary.applyChanges(changes);
}
dispose() {
this._roomEncryption?.dispose();
this._timeline?.dispose();
}
}
class DecryptionRequest {