From 87fbbb9a3f4410c9815733772fd52cae79f4fc8a Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 15 Dec 2025 15:16:47 -0500 Subject: [PATCH] Make MatrixRTC mode a required input to CallViewModel --- src/state/CallViewModel/CallViewModel.ts | 11 ++++------- src/state/CallViewModel/CallViewModelTestUtils.ts | 11 +++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/state/CallViewModel/CallViewModel.ts b/src/state/CallViewModel/CallViewModel.ts index 9ebe025c..8f8b20cf 100644 --- a/src/state/CallViewModel/CallViewModel.ts +++ b/src/state/CallViewModel/CallViewModel.ts @@ -62,7 +62,6 @@ import { import { duplicateTiles, MatrixRTCMode, - matrixRTCMode as matrixRTCModeSetting, playReactionsSound, showReactions, } from "../../settings/settings"; @@ -156,8 +155,8 @@ export interface CallViewModelOptions { connectionState$?: Behavior; /** Optional behavior overriding the computed window size, mainly for testing purposes. */ windowSize$?: Behavior<{ width: number; height: number }>; - /** Optional behavior overriding the MatrixRTC mode, mainly for testing purposes. */ - matrixRTCMode$?: Behavior; + /** The version & compatibility mode of MatrixRTC that we should use. */ + matrixRTCMode$: Behavior; } // Do not play any sounds if the participant count has exceeded this @@ -408,15 +407,13 @@ export function createCallViewModel$( memberships$, ); - const matrixRTCMode$ = options.matrixRTCMode$ ?? matrixRTCModeSetting.value$; - const localTransport$ = createLocalTransport$({ scope: scope, memberships$: memberships$, client, roomId: matrixRoom.roomId, useOldestMember$: scope.behavior( - matrixRTCMode$.pipe(map((v) => v === MatrixRTCMode.Legacy)), + options.matrixRTCMode$.pipe(map((v) => v === MatrixRTCMode.Legacy)), ), }); @@ -468,7 +465,7 @@ export function createCallViewModel$( }); const connectOptions$ = scope.behavior( - matrixRTCMode$.pipe( + options.matrixRTCMode$.pipe( map((mode) => ({ encryptMedia: livekitKeyProvider !== undefined, // TODO. This might need to get called again on each change of matrixRTCMode... diff --git a/src/state/CallViewModel/CallViewModelTestUtils.ts b/src/state/CallViewModel/CallViewModelTestUtils.ts index 377c6771..b6f53275 100644 --- a/src/state/CallViewModel/CallViewModelTestUtils.ts +++ b/src/state/CallViewModel/CallViewModelTestUtils.ts @@ -102,11 +102,7 @@ export function withCallViewModel(mode: MatrixRTCMode) { }, setSyncState: (value: SyncState) => void, ) => void, - options: CallViewModelOptions = { - encryptionSystem: { kind: E2eeType.PER_PARTICIPANT }, - autoLeaveWhenOthersLeft: false, - matrixRTCMode$: constant(mode), - }, + options: Partial = {}, ): void => { let syncState = initialSyncState; const setSyncState = (value: SyncState): void => { @@ -176,7 +172,8 @@ export function withCallViewModel(mode: MatrixRTCMode) { mediaDevices, muteStates, { - ...options, + encryptionSystem: { kind: E2eeType.PER_PARTICIPANT }, + autoLeaveWhenOthersLeft: false, livekitRoomFactory: (): LivekitRoom => mockLivekitRoom({ localParticipant, @@ -185,6 +182,8 @@ export function withCallViewModel(mode: MatrixRTCMode) { }), connectionState$, windowSize$, + matrixRTCMode$: constant(mode), + ...options, }, raisedHands$, reactions$,