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 {