Skip to content

Commit 87fbbb9

Browse files
committed
Make MatrixRTC mode a required input to CallViewModel
1 parent c7e9f1c commit 87fbbb9

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/state/CallViewModel/CallViewModel.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ import {
6262
import {
6363
duplicateTiles,
6464
MatrixRTCMode,
65-
matrixRTCMode as matrixRTCModeSetting,
6665
playReactionsSound,
6766
showReactions,
6867
} from "../../settings/settings";
@@ -156,8 +155,8 @@ export interface CallViewModelOptions {
156155
connectionState$?: Behavior<ConnectionState>;
157156
/** Optional behavior overriding the computed window size, mainly for testing purposes. */
158157
windowSize$?: Behavior<{ width: number; height: number }>;
159-
/** Optional behavior overriding the MatrixRTC mode, mainly for testing purposes. */
160-
matrixRTCMode$?: Behavior<MatrixRTCMode>;
158+
/** The version & compatibility mode of MatrixRTC that we should use. */
159+
matrixRTCMode$: Behavior<MatrixRTCMode>;
161160
}
162161

163162
// Do not play any sounds if the participant count has exceeded this
@@ -408,15 +407,13 @@ export function createCallViewModel$(
408407
memberships$,
409408
);
410409

411-
const matrixRTCMode$ = options.matrixRTCMode$ ?? matrixRTCModeSetting.value$;
412-
413410
const localTransport$ = createLocalTransport$({
414411
scope: scope,
415412
memberships$: memberships$,
416413
client,
417414
roomId: matrixRoom.roomId,
418415
useOldestMember$: scope.behavior(
419-
matrixRTCMode$.pipe(map((v) => v === MatrixRTCMode.Legacy)),
416+
options.matrixRTCMode$.pipe(map((v) => v === MatrixRTCMode.Legacy)),
420417
),
421418
});
422419

@@ -468,7 +465,7 @@ export function createCallViewModel$(
468465
});
469466

470467
const connectOptions$ = scope.behavior(
471-
matrixRTCMode$.pipe(
468+
options.matrixRTCMode$.pipe(
472469
map((mode) => ({
473470
encryptMedia: livekitKeyProvider !== undefined,
474471
// TODO. This might need to get called again on each change of matrixRTCMode...

src/state/CallViewModel/CallViewModelTestUtils.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ export function withCallViewModel(mode: MatrixRTCMode) {
102102
},
103103
setSyncState: (value: SyncState) => void,
104104
) => void,
105-
options: CallViewModelOptions = {
106-
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
107-
autoLeaveWhenOthersLeft: false,
108-
matrixRTCMode$: constant(mode),
109-
},
105+
options: Partial<CallViewModelOptions> = {},
110106
): void => {
111107
let syncState = initialSyncState;
112108
const setSyncState = (value: SyncState): void => {
@@ -176,7 +172,8 @@ export function withCallViewModel(mode: MatrixRTCMode) {
176172
mediaDevices,
177173
muteStates,
178174
{
179-
...options,
175+
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
176+
autoLeaveWhenOthersLeft: false,
180177
livekitRoomFactory: (): LivekitRoom =>
181178
mockLivekitRoom({
182179
localParticipant,
@@ -185,6 +182,8 @@ export function withCallViewModel(mode: MatrixRTCMode) {
185182
}),
186183
connectionState$,
187184
windowSize$,
185+
matrixRTCMode$: constant(mode),
186+
...options,
188187
},
189188
raisedHands$,
190189
reactions$,

0 commit comments

Comments
 (0)