Make MatrixRTC mode a required input to CallViewModel

This commit is contained in:
Robin
2025-12-15 15:16:47 -05:00
parent c7e9f1ce14
commit 87fbbb9a3f
2 changed files with 9 additions and 13 deletions

View File

@@ -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<ConnectionState>;
/** 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<MatrixRTCMode>;
/** The version & compatibility mode of MatrixRTC that we should use. */
matrixRTCMode$: Behavior<MatrixRTCMode>;
}
// 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...

View File

@@ -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<CallViewModelOptions> = {},
): 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$,