diff --git a/src/domain/SessionLoadViewModel.js b/src/domain/SessionLoadViewModel.js index 0511d8a7..e9454a24 100644 --- a/src/domain/SessionLoadViewModel.js +++ b/src/domain/SessionLoadViewModel.js @@ -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(); } diff --git a/src/matrix/Session.js b/src/matrix/Session.js index 3d8b390b..3a89dcf3 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -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) { diff --git a/src/matrix/e2ee/RoomEncryption.js b/src/matrix/e2ee/RoomEncryption.js index 06485510..44caae1b 100644 --- a/src/matrix/e2ee/RoomEncryption.js +++ b/src/matrix/e2ee/RoomEncryption.js @@ -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; + } } /** diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index 1a65c1fd..db61aa14 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -529,6 +529,11 @@ export class Room extends EventEmitter { applyIsTrackingMembersChanges(changes) { this._summary.applyChanges(changes); } + + dispose() { + this._roomEncryption?.dispose(); + this._timeline?.dispose(); + } } class DecryptionRequest {