From 9176d3a671114be97ee7a42155a6d40a233384f1 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Wed, 7 Aug 2024 11:44:44 -0400 Subject: [PATCH] Use non-legacy calls if any are found (#4337) Akin to how legacy call events should be sent in rooms where there is any ongoing legacy call, send non-legacy events in rooms where there are only non-legacy calls; else fall back to the config preference. --- src/matrixrtc/MatrixRTCSession.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/matrixrtc/MatrixRTCSession.ts b/src/matrixrtc/MatrixRTCSession.ts index c15b0181507..0b4fe1b1c89 100644 --- a/src/matrixrtc/MatrixRTCSession.ts +++ b/src/matrixrtc/MatrixRTCSession.ts @@ -826,9 +826,7 @@ export class MatrixRTCSession extends TypedEventEmitter): boolean { + private stateEventsContainOngoingLegacySession(callMemberEvents: Map | undefined): boolean { + if (!callMemberEvents?.size) { + return this.useLegacyMemberEvents; + } + + let containsAnyOngoingSession = false; + let containsUnknownOngoingSession = false; for (const callMemberEvent of callMemberEvents.values()) { const content = callMemberEvent.getContent(); if (Array.isArray(content["memberships"])) { @@ -926,9 +930,12 @@ export class MatrixRTCSession extends TypedEventEmitter 0) { + containsAnyOngoingSession ||= true; + containsUnknownOngoingSession ||= !("focus_active" in content); } } - return false; + return containsAnyOngoingSession && !containsUnknownOngoingSession ? false : this.useLegacyMemberEvents; } private makeMembershipStateKey(localUserId: string, localDeviceId: string): string {