From 506ec7f2abb1a3ea03ce339886d68d9c8fd47ffc Mon Sep 17 00:00:00 2001 From: Timo Date: Fri, 10 Jan 2025 16:48:12 +0100 Subject: [PATCH] move update condition into MembershipManager --- src/matrixrtc/MatrixRTCSession.ts | 6 +----- src/matrixrtc/MembershipManager.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/matrixrtc/MatrixRTCSession.ts b/src/matrixrtc/MatrixRTCSession.ts index d4fd00ee22..3c311ccf4a 100644 --- a/src/matrixrtc/MatrixRTCSession.ts +++ b/src/matrixrtc/MatrixRTCSession.ts @@ -781,11 +781,7 @@ export class MatrixRTCSession extends TypedEventEmitter; - onMembershipsUpdate(): Promise; + onMembershipsUpdate(memberships: CallMembership[]): Promise; getActiveFocus(): Focus | undefined; } @@ -135,8 +135,15 @@ export class MembershipManager implements MembershipManagerInterface { } } - public async onMembershipsUpdate(): Promise { - return this.triggerCallMembershipEventUpdate(); + public async onMembershipsUpdate(memberships: CallMembership[]): Promise { + const isMyMembership = (m: CallMembership): boolean => + m.sender === this.client.getUserId() && m.deviceId === this.client.getDeviceId(); + + if (this.isJoined() && !memberships.some(isMyMembership)) { + logger.warn("Missing own membership: force re-join"); + // TODO: Should this be awaited? And is there anything to tell the focus? + return this.triggerCallMembershipEventUpdate(); + } } public getActiveFocus(): Focus | undefined {