From 2ecfb8f13911cd1ec35fcb92ba1227ecf5162d40 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Thu, 6 Oct 2022 15:22:15 +0200 Subject: [PATCH] unify dispose logic in Member --- src/matrix/calls/group/Member.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/matrix/calls/group/Member.ts b/src/matrix/calls/group/Member.ts index d4cc93f4..5f6325b5 100644 --- a/src/matrix/calls/group/Member.ts +++ b/src/matrix/calls/group/Member.ts @@ -83,6 +83,12 @@ class MemberConnection { return first.content.seq === this.lastProcessedSeqNr || first.content.seq === this.lastProcessedSeqNr + 1; } + + dispose() { + this.peerCall?.dispose(); + this.localMedia.dispose(); + this.logItem.finish(); + } } export class Member { @@ -210,18 +216,15 @@ export class Member { return; } let disconnectLogItem; + // if if not sending the hangup, still log disconnect connection.logItem.wrap("disconnect", async log => { disconnectLogItem = log; - if (hangup) { - await connection.peerCall?.hangup(CallErrorCode.UserHangup, log); - } else { - await connection.peerCall?.close(undefined, log); + if (hangup && connection.peerCall) { + await connection.peerCall.hangup(CallErrorCode.UserHangup, log); } - connection.peerCall?.dispose(); - connection.localMedia?.dispose(); - this.connection = undefined; }); - connection.logItem.finish(); + connection.dispose(); + this.connection = undefined; return disconnectLogItem; } @@ -395,8 +398,10 @@ export class Member { } dispose() { + this.connection?.dispose(); + this.connection = undefined; this.expireTimeout?.dispose(); - this.connection?.peerCall?.dispose(); + this.expireTimeout = undefined; } }