mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-08 20:09:19 +00:00
Make mediaDevices less confusing
This commit is contained in:
@@ -101,6 +101,7 @@ interface CreateInCallViewArgs {
|
|||||||
function createInCallView(args: CreateInCallViewArgs = {}): RenderResult & {
|
function createInCallView(args: CreateInCallViewArgs = {}): RenderResult & {
|
||||||
rtcSession: MockRTCSession;
|
rtcSession: MockRTCSession;
|
||||||
} {
|
} {
|
||||||
|
const mediaDevices = args.mediaDevices ?? mockMediaDevices({});
|
||||||
const muteState = mockMuteStates();
|
const muteState = mockMuteStates();
|
||||||
const livekitRoom = mockLivekitRoom(
|
const livekitRoom = mockLivekitRoom(
|
||||||
{
|
{
|
||||||
@@ -113,7 +114,11 @@ function createInCallView(args: CreateInCallViewArgs = {}): RenderResult & {
|
|||||||
const { vm, rtcSession } = getBasicCallViewModelEnvironment(
|
const { vm, rtcSession } = getBasicCallViewModelEnvironment(
|
||||||
[local, alice],
|
[local, alice],
|
||||||
undefined,
|
undefined,
|
||||||
{ mediaDeviceOverride: args.mediaDevices },
|
mediaDevices,
|
||||||
|
{
|
||||||
|
toggleScreensharing: () => {},
|
||||||
|
...args.callViewModelOptions,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
rtcSession.joined = true;
|
rtcSession.joined = true;
|
||||||
@@ -121,7 +126,7 @@ function createInCallView(args: CreateInCallViewArgs = {}): RenderResult & {
|
|||||||
const client = room.client;
|
const client = room.client;
|
||||||
const renderResult = render(
|
const renderResult = render(
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<MediaDevicesContext value={args.mediaDevices ?? mockMediaDevices({})}>
|
<MediaDevicesContext value={mediaDevices}>
|
||||||
<ReactionsSenderProvider
|
<ReactionsSenderProvider
|
||||||
vm={vm}
|
vm={vm}
|
||||||
rtcSession={rtcSession.asMockedSession()}
|
rtcSession={rtcSession.asMockedSession()}
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ export interface CallViewModelOptions {
|
|||||||
windowSize$?: Behavior<{ width: number; height: number }>;
|
windowSize$?: Behavior<{ width: number; height: number }>;
|
||||||
/** The version & compatibility mode of MatrixRTC that we should use. */
|
/** The version & compatibility mode of MatrixRTC that we should use. */
|
||||||
matrixRTCMode$?: Behavior<MatrixRTCMode>;
|
matrixRTCMode$?: Behavior<MatrixRTCMode>;
|
||||||
mediaDeviceOverride?: MediaDevices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not play any sounds if the participant count has exceeded this
|
// Do not play any sounds if the participant count has exceeded this
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import {
|
|||||||
MockRTCSession,
|
MockRTCSession,
|
||||||
testScope,
|
testScope,
|
||||||
} from "./test";
|
} from "./test";
|
||||||
|
import { type MediaDevices } from "../state/MediaDevices";
|
||||||
import { aliceRtcMember, localRtcMember } from "./test-fixtures";
|
import { aliceRtcMember, localRtcMember } from "./test-fixtures";
|
||||||
import { type RaisedHandInfo, type ReactionInfo } from "../reactions";
|
import { type RaisedHandInfo, type ReactionInfo } from "../reactions";
|
||||||
import { constant } from "../state/Behavior";
|
import { constant } from "../state/Behavior";
|
||||||
@@ -131,6 +132,7 @@ export function getBasicRTCSession(
|
|||||||
export function getBasicCallViewModelEnvironment(
|
export function getBasicCallViewModelEnvironment(
|
||||||
members: RoomMember[],
|
members: RoomMember[],
|
||||||
initialRtcMemberships: CallMembership[] = [localRtcMember, aliceRtcMember],
|
initialRtcMemberships: CallMembership[] = [localRtcMember, aliceRtcMember],
|
||||||
|
mediaDevicesOverride?: MediaDevices,
|
||||||
callViewModelOptions: Partial<CallViewModelOptions> = {},
|
callViewModelOptions: Partial<CallViewModelOptions> = {},
|
||||||
): {
|
): {
|
||||||
vm: CallViewModel;
|
vm: CallViewModel;
|
||||||
@@ -146,13 +148,11 @@ export function getBasicCallViewModelEnvironment(
|
|||||||
const handRaisedSubject$ = new BehaviorSubject({});
|
const handRaisedSubject$ = new BehaviorSubject({});
|
||||||
const reactionsSubject$ = new BehaviorSubject({});
|
const reactionsSubject$ = new BehaviorSubject({});
|
||||||
|
|
||||||
// const remoteParticipants$ = of([aliceParticipant]);
|
|
||||||
|
|
||||||
const vm = createCallViewModel$(
|
const vm = createCallViewModel$(
|
||||||
testScope(),
|
testScope(),
|
||||||
rtcSession.asMockedSession(),
|
rtcSession.asMockedSession(),
|
||||||
matrixRoom,
|
matrixRoom,
|
||||||
callViewModelOptions.mediaDeviceOverride ?? mockMediaDevices({}),
|
mediaDevicesOverride ?? mockMediaDevices({}),
|
||||||
mockMuteStates(),
|
mockMuteStates(),
|
||||||
{
|
{
|
||||||
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
|
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
|
||||||
|
|||||||
Reference in New Issue
Block a user