mirror of
https://github.com/element-hq/element-call.git
synced 2026-11-22 22:08:34 +00:00
remove the rtcSession from everything below the CallView!!!!
This is a big step in the js-sdk independence of EC. It concludes a clear position where we can start building the matrixBackend.
This commit is contained in:
1 parent
d492b9d93a
commit
0f5969677f
19 files changed
+403
-386
No files matched your search
+12
-1
@@ -61,6 +61,7 @@ import LanguageDetector from "i18next-browser-languagedetector";
|
||||
|
||||
import EN from "../locales/en/app.json";
|
||||
import { CallView } from "../src/room/CallView";
|
||||
import { observeSentCallNotification$ } from "../src/state/CallViewModel/CallNotificationLifecycle";
|
||||
import { ErrorPage } from "../src/FullScreenView";
|
||||
import { ClientProvider } from "../src/ClientContext";
|
||||
import { HostBridgeProvider } from "../src/HostBridge";
|
||||
@@ -269,6 +270,10 @@ export const ElementCall: FC<ElementCallProps> = ({
|
||||
void session.stop();
|
||||
};
|
||||
}, [client, room]);
|
||||
const sentCallNotification$ = useMemo(
|
||||
() => rtcSession && observeSentCallNotification$(rtcSession),
|
||||
[rtcSession],
|
||||
);
|
||||
|
||||
if (room === null)
|
||||
logger.error(
|
||||
@@ -281,7 +286,11 @@ export const ElementCall: FC<ElementCallProps> = ({
|
||||
// its own initialisation is over. Once per mount, however often the pieces
|
||||
// are later swapped out.
|
||||
const ready =
|
||||
container !== null && room !== null && rtcSession !== null && vm !== null;
|
||||
container !== null &&
|
||||
room !== null &&
|
||||
rtcSession !== null &&
|
||||
sentCallNotification$ !== null &&
|
||||
vm !== null;
|
||||
const announcedLoaded = useRef(false);
|
||||
useEffect(() => {
|
||||
if (!ready || announcedLoaded.current) return;
|
||||
@@ -320,6 +329,8 @@ export const ElementCall: FC<ElementCallProps> = ({
|
||||
client={callViewClient}
|
||||
room={room}
|
||||
rtcSession={rtcSession}
|
||||
sentCallNotification$={sentCallNotification$}
|
||||
statistics={rtcSession.statistics}
|
||||
isPasswordlessUser={false}
|
||||
confineToRoom={params.confineToRoom}
|
||||
preload={params.preload}
|
||||
|
||||
@@ -118,8 +118,6 @@
|
||||
"livekit_connection_error": "Failed to connect to Livekit server",
|
||||
"livekit_connection_error_description": "An error occurred while connecting to the Livekit server (<1>Reason:</1> <2>{{ reason }}</2>).",
|
||||
"matrix_rtc_transport_missing": "The server is not configured to work with {{brand}} and no other call participant provides a usable transport. Please contact your server admin (Domain: {{domain}}, Error Code: {{ errorCode }}).",
|
||||
"membership_manager": "Membership Manager Error",
|
||||
"membership_manager_description": "The Membership Manager had to shut down. This is caused by many consecutive failed network requests.",
|
||||
"no_matrix_2_authorization_service": "The authorization service for your media server (SFU) is out of date.",
|
||||
"open_elsewhere": "Opened in another tab",
|
||||
"open_elsewhere_description": "{{brand}} has been opened in another tab. If that doesn't sound right, try reloading the page.",
|
||||
|
||||
@@ -41,7 +41,6 @@ import {
|
||||
import {
|
||||
captureSettings,
|
||||
rtcParticipationOptions,
|
||||
rtcSlotOptions,
|
||||
} from "../src/room/InCallView";
|
||||
import { createWidgetHostBridge } from "../src/HostBridge";
|
||||
import { MediaDevices } from "../src/state/MediaDevices";
|
||||
@@ -103,7 +102,7 @@ export async function createMatrixRTCSdk(
|
||||
scope,
|
||||
client,
|
||||
room,
|
||||
rtcSlotOptions(encryptionSystem),
|
||||
{ encryptionSystem },
|
||||
sessionManager(scope, client, { application, id }, logger).getRoomSession(
|
||||
room,
|
||||
),
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
afterAll,
|
||||
} from "vitest";
|
||||
import { logger } from "matrix-js-sdk/lib/logger";
|
||||
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { type Statistics } from "matrix-js-sdk/lib/matrixrtc";
|
||||
|
||||
import { PosthogAnalytics } from "./PosthogAnalytics";
|
||||
import {
|
||||
@@ -34,16 +34,14 @@ const defaultTotals = {
|
||||
roomEventEncryptionKeysReceivedTotalAge: 500,
|
||||
};
|
||||
|
||||
function createMockRtcSession(overrides?: {
|
||||
function createMockStatistics(overrides?: {
|
||||
counters?: Partial<typeof defaultCounters>;
|
||||
totals?: Partial<typeof defaultTotals>;
|
||||
}): MatrixRTCSession {
|
||||
}): Statistics {
|
||||
return {
|
||||
statistics: {
|
||||
counters: { ...defaultCounters, ...overrides?.counters },
|
||||
totals: { ...defaultTotals, ...overrides?.totals },
|
||||
},
|
||||
} as unknown as MatrixRTCSession;
|
||||
counters: { ...defaultCounters, ...overrides?.counters },
|
||||
totals: { ...defaultTotals, ...overrides?.totals },
|
||||
} as Statistics;
|
||||
}
|
||||
|
||||
describe("CallEnded", () => {
|
||||
@@ -65,9 +63,9 @@ describe("CallEnded", () => {
|
||||
it("warns if startTime is missing when track is called", () => {
|
||||
const warnSpy = vi.spyOn(logger, "warn");
|
||||
const tracker = new CallEndedTracker();
|
||||
const mockSession = createMockRtcSession();
|
||||
const statistics = createMockStatistics();
|
||||
|
||||
tracker.track("test-call-id", 2, false, mockSession);
|
||||
tracker.track("test-call-id", 2, false, statistics);
|
||||
|
||||
expect(warnSpy).toHaveBeenCalledWith(
|
||||
"[PosthogEvents] Failed to send posthog callEnded event due to missing startTime",
|
||||
@@ -77,11 +75,11 @@ describe("CallEnded", () => {
|
||||
|
||||
it("tracks event with correct properties when startTime is set", () => {
|
||||
const tracker = new CallEndedTracker();
|
||||
const mockSession = createMockRtcSession();
|
||||
const statistics = createMockStatistics();
|
||||
|
||||
tracker.cacheStartCall(new Date(Date.now() - 60000));
|
||||
tracker.cacheParticipantCountChanged(5);
|
||||
tracker.track("test-call-id", 3, true, mockSession);
|
||||
tracker.track("test-call-id", 3, true, statistics);
|
||||
|
||||
expect(PosthogAnalytics.instance.trackEvent).toHaveBeenCalledWith(
|
||||
{
|
||||
@@ -105,13 +103,13 @@ describe("CallEnded", () => {
|
||||
|
||||
it("tracks maxParticipantsCount correctly across multiple changes", () => {
|
||||
const tracker = new CallEndedTracker();
|
||||
const mockSession = createMockRtcSession();
|
||||
const statistics = createMockStatistics();
|
||||
|
||||
tracker.cacheStartCall(new Date());
|
||||
tracker.cacheParticipantCountChanged(3);
|
||||
tracker.cacheParticipantCountChanged(7);
|
||||
tracker.cacheParticipantCountChanged(2);
|
||||
tracker.track("test-call-id", 1, false, mockSession);
|
||||
tracker.track("test-call-id", 1, false, statistics);
|
||||
|
||||
expect(PosthogAnalytics.instance.trackEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -123,12 +121,12 @@ describe("CallEnded", () => {
|
||||
|
||||
it("computes roomEventEncryptionKeysReceivedAverageAge as 0 when no keys received", () => {
|
||||
const tracker = new CallEndedTracker();
|
||||
const mockSession = createMockRtcSession({
|
||||
const statistics = createMockStatistics({
|
||||
counters: { roomEventEncryptionKeysReceived: 0 },
|
||||
});
|
||||
|
||||
tracker.cacheStartCall(new Date());
|
||||
tracker.track("test-call-id", 1, false, mockSession);
|
||||
tracker.track("test-call-id", 1, false, statistics);
|
||||
|
||||
expect(PosthogAnalytics.instance.trackEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -140,13 +138,13 @@ describe("CallEnded", () => {
|
||||
|
||||
it("computes roomEventEncryptionKeysReceivedAverageAge correctly when keys are received", () => {
|
||||
const tracker = new CallEndedTracker();
|
||||
const mockSession = createMockRtcSession({
|
||||
const statistics = createMockStatistics({
|
||||
counters: { roomEventEncryptionKeysReceived: 4 },
|
||||
totals: { roomEventEncryptionKeysReceivedTotalAge: 200 },
|
||||
});
|
||||
|
||||
tracker.cacheStartCall(new Date());
|
||||
tracker.track("test-call-id", 1, false, mockSession);
|
||||
tracker.track("test-call-id", 1, false, statistics);
|
||||
|
||||
expect(PosthogAnalytics.instance.trackEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -158,10 +156,10 @@ describe("CallEnded", () => {
|
||||
|
||||
it("passes send_instantly option correctly", () => {
|
||||
const tracker = new CallEndedTracker();
|
||||
const mockSession = createMockRtcSession();
|
||||
const statistics = createMockStatistics();
|
||||
|
||||
tracker.cacheStartCall(new Date());
|
||||
tracker.track("test-call-id", 1, false, mockSession);
|
||||
tracker.track("test-call-id", 1, false, statistics);
|
||||
|
||||
expect(PosthogAnalytics.instance.trackEvent).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
@@ -171,14 +169,14 @@ describe("CallEnded", () => {
|
||||
|
||||
it("includes per-reason reconnecting counts in CallEnded", () => {
|
||||
const tracker = new CallEndedTracker();
|
||||
const mockSession = createMockRtcSession();
|
||||
const statistics = createMockStatistics();
|
||||
|
||||
tracker.cacheStartCall(new Date());
|
||||
tracker.cacheReconnecting("sync");
|
||||
tracker.cacheReconnecting("sync");
|
||||
tracker.cacheReconnecting("livekit");
|
||||
tracker.cacheReconnecting("membership");
|
||||
tracker.track("test-call-id", 1, false, mockSession);
|
||||
tracker.track("test-call-id", 1, false, statistics);
|
||||
|
||||
expect(PosthogAnalytics.instance.trackEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
import { type DisconnectReason } from "livekit-client";
|
||||
import { logger } from "matrix-js-sdk/lib/logger";
|
||||
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { type Statistics } from "matrix-js-sdk/lib/matrixrtc";
|
||||
|
||||
import {
|
||||
type IPosthogEvent,
|
||||
@@ -80,7 +80,7 @@ export class CallEndedTracker {
|
||||
callId: string,
|
||||
callParticipantsNow: number,
|
||||
sendInstantly: boolean,
|
||||
rtcSession: MatrixRTCSession,
|
||||
statistics: Statistics,
|
||||
): void {
|
||||
if (this.cache.startTime) {
|
||||
PosthogAnalytics.instance.trackEvent<CallEnded>(
|
||||
@@ -91,14 +91,13 @@ export class CallEndedTracker {
|
||||
callParticipantsOnLeave: callParticipantsNow,
|
||||
callDuration: (Date.now() - this.cache.startTime.getTime()) / 1000,
|
||||
roomEventEncryptionKeysSent:
|
||||
rtcSession.statistics.counters.roomEventEncryptionKeysSent,
|
||||
statistics.counters.roomEventEncryptionKeysSent,
|
||||
roomEventEncryptionKeysReceived:
|
||||
rtcSession.statistics.counters.roomEventEncryptionKeysReceived,
|
||||
statistics.counters.roomEventEncryptionKeysReceived,
|
||||
roomEventEncryptionKeysReceivedAverageAge:
|
||||
rtcSession.statistics.counters.roomEventEncryptionKeysReceived > 0
|
||||
? rtcSession.statistics.totals
|
||||
.roomEventEncryptionKeysReceivedTotalAge /
|
||||
rtcSession.statistics.counters.roomEventEncryptionKeysReceived
|
||||
statistics.counters.roomEventEncryptionKeysReceived > 0
|
||||
? statistics.totals.roomEventEncryptionKeysReceivedTotalAge /
|
||||
statistics.counters.roomEventEncryptionKeysReceived
|
||||
: 0,
|
||||
callReconnectingCount: this.cache.reconnectingCount,
|
||||
callReconnectingCountSync: this.cache.reconnectingCountByReason.sync,
|
||||
|
||||
+40
-77
@@ -19,16 +19,8 @@ import {
|
||||
vitest,
|
||||
} from "vitest";
|
||||
import { render, waitFor, screen, act } from "@testing-library/react";
|
||||
import {
|
||||
type MatrixClient,
|
||||
JoinRule,
|
||||
type RoomState,
|
||||
UnsupportedStickyEventsEndpointError,
|
||||
} from "matrix-js-sdk";
|
||||
import {
|
||||
MatrixRTCSessionEvent,
|
||||
type MatrixRTCSession,
|
||||
} from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { type MatrixClient, JoinRule, type RoomState } from "matrix-js-sdk";
|
||||
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import userEvent, {
|
||||
PointerEventsCheckLevel,
|
||||
@@ -36,7 +28,7 @@ import userEvent, {
|
||||
import { type RelationsContainer } from "matrix-js-sdk/lib/models/relations-container";
|
||||
import { useState } from "react";
|
||||
import { TooltipProvider } from "@vector-im/compound-web";
|
||||
import { Subject } from "rxjs";
|
||||
import { NEVER, Subject } from "rxjs";
|
||||
import { Room as LivekitRoom } from "livekit-client";
|
||||
|
||||
import { prefetchSounds } from "../soundUtils";
|
||||
@@ -53,7 +45,6 @@ import {
|
||||
testScope,
|
||||
} from "../utils/test";
|
||||
import { CallView } from "./CallView";
|
||||
import { GroupCallErrorBoundary } from "./GroupCallErrorBoundary";
|
||||
import {
|
||||
type HostBridge,
|
||||
HostBridgeProvider,
|
||||
@@ -61,7 +52,10 @@ import {
|
||||
nullHostBridge,
|
||||
} from "../HostBridge";
|
||||
import { type JoinCallData } from "../widget";
|
||||
import { MatrixRTCTransportMissingError } from "../utils/errors";
|
||||
import {
|
||||
ConnectionLostError,
|
||||
MatrixRTCTransportMissingError,
|
||||
} from "../utils/errors";
|
||||
import {
|
||||
BackgroundEffectsProvider,
|
||||
createAppBackgroundEffects,
|
||||
@@ -146,7 +140,6 @@ function createCallView(
|
||||
hostBridge: HostBridge,
|
||||
joined = true,
|
||||
options: {
|
||||
withErrorBoundary?: boolean;
|
||||
/** Wait for the host to say when to join, rather than joining at once. */
|
||||
preload?: boolean;
|
||||
} = {},
|
||||
@@ -170,6 +163,7 @@ function createCallView(
|
||||
client,
|
||||
roomId,
|
||||
getMember: (userId) => roomMembers.get(userId) ?? null,
|
||||
getMembersWithMembership: () => [carol],
|
||||
getMxcAvatarUrl: () => null,
|
||||
getCanonicalAlias: () => null,
|
||||
currentState: {
|
||||
@@ -181,18 +175,6 @@ function createCallView(
|
||||
constant([localRtcMember]),
|
||||
);
|
||||
rtcSession.joined = joined;
|
||||
const callView = (
|
||||
<CallView
|
||||
client={client}
|
||||
room={room}
|
||||
isPasswordlessUser={false}
|
||||
confineToRoom={false}
|
||||
preload={options.preload ?? false}
|
||||
// Straight into the (mocked) call, past the lobby
|
||||
skipLobby
|
||||
rtcSession={rtcSession.asMockedSession()}
|
||||
/>
|
||||
);
|
||||
const { getByText } = render(
|
||||
<BrowserRouter>
|
||||
<HostBridgeProvider value={hostBridge}>
|
||||
@@ -201,13 +183,18 @@ function createCallView(
|
||||
<BackgroundEffectsProvider
|
||||
effects={createAppBackgroundEffects(testScope())}
|
||||
>
|
||||
{options.withErrorBoundary ? (
|
||||
<GroupCallErrorBoundary recoveryActionHandler={vi.fn()}>
|
||||
{callView}
|
||||
</GroupCallErrorBoundary>
|
||||
) : (
|
||||
callView
|
||||
)}
|
||||
<CallView
|
||||
client={client}
|
||||
room={room}
|
||||
isPasswordlessUser={false}
|
||||
confineToRoom={false}
|
||||
preload={options.preload ?? false}
|
||||
// Straight into the (mocked) call, past the lobby
|
||||
skipLobby
|
||||
rtcSession={rtcSession.asMockedSession()}
|
||||
sentCallNotification$={NEVER}
|
||||
statistics={rtcSession.asMockedSession().statistics}
|
||||
/>
|
||||
</BackgroundEffectsProvider>
|
||||
</MediaDevicesContext>
|
||||
</TooltipProvider>
|
||||
@@ -372,52 +359,28 @@ test.skip("CallView shows errors that occur during joining", async () => {
|
||||
screen.getByText("Call is not supported");
|
||||
});
|
||||
|
||||
test("translates wrapped UnsupportedStickyEventsEndpointError to the StickyEventsRequiredError screen", async () => {
|
||||
// Mirror the shape the SDK emits: the MembershipManager scheduler wraps
|
||||
// the original UnsupportedStickyEventsEndpointError in a generic Error
|
||||
// but preserves the original on `.cause`.
|
||||
const stickyError = new UnsupportedStickyEventsEndpointError(
|
||||
"Server does not support the sticky events",
|
||||
"sendStickyEvent",
|
||||
test("user can reconnect after losing the connection", async () => {
|
||||
// What the call throws once the view model reports the connection lost
|
||||
(ActiveCall as MockedFunction<typeof ActiveCall>).mockImplementation(
|
||||
({ onLeft }) => {
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
if (error !== null) throw error;
|
||||
return (
|
||||
<div>
|
||||
<button onClick={() => onLeft("user")}>Leave</button>
|
||||
<button onClick={() => setError(new ConnectionLostError())}>
|
||||
LoseConnection
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
const wrappedError = new Error(
|
||||
"The MembershipManager shut down because of the end condition: " +
|
||||
String(stickyError),
|
||||
{ cause: stickyError },
|
||||
);
|
||||
|
||||
const { rtcSession } = createCallView(nullHostBridge, true, {
|
||||
withErrorBoundary: true,
|
||||
});
|
||||
|
||||
await act(() =>
|
||||
rtcSession.emit(MatrixRTCSessionEvent.MembershipManagerError, wrappedError),
|
||||
);
|
||||
|
||||
await screen.findByText("Homeserver does not support Matrix 2.0 calls");
|
||||
});
|
||||
|
||||
test("falls back to ConnectionLostError for unrecognised membership manager errors", async () => {
|
||||
const { rtcSession } = createCallView(nullHostBridge, true, {
|
||||
withErrorBoundary: true,
|
||||
});
|
||||
|
||||
await act(() =>
|
||||
rtcSession.emit(
|
||||
MatrixRTCSessionEvent.MembershipManagerError,
|
||||
new Error("something else broke"),
|
||||
),
|
||||
);
|
||||
|
||||
await screen.findByText("Connection lost");
|
||||
});
|
||||
|
||||
test("user can reconnect after a membership manager error", async () => {
|
||||
const user = userEvent.setup();
|
||||
const { rtcSession } = createCallView(nullHostBridge, true);
|
||||
await act(() =>
|
||||
rtcSession.emit(MatrixRTCSessionEvent.MembershipManagerError, undefined),
|
||||
);
|
||||
createCallView(nullHostBridge, true);
|
||||
await user.click(screen.getByRole("button", { name: "LoseConnection" }));
|
||||
await screen.findByText("Connection lost");
|
||||
// Never joined, so there was no call to leave
|
||||
expect(playSound).not.toHaveBeenCalled();
|
||||
// XXX: Wrapping the following click in act() shouldn't be necessary (the
|
||||
// async state update should be processed automatically by the waitFor call),
|
||||
// and yet here we are.
|
||||
|
||||
+155
-81
@@ -13,21 +13,23 @@ import {
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import {
|
||||
type MatrixClient,
|
||||
JoinRule,
|
||||
type Room,
|
||||
UnsupportedStickyEventsEndpointError,
|
||||
} from "matrix-js-sdk";
|
||||
import { type MatrixClient, JoinRule, type Room } from "matrix-js-sdk";
|
||||
import {
|
||||
Room as LivekitRoom,
|
||||
isE2EESupported as isE2EESupportedBrowser,
|
||||
} from "livekit-client";
|
||||
import { logger } from "matrix-js-sdk/lib/logger";
|
||||
import {
|
||||
MatrixRTCSessionEvent,
|
||||
type MatrixRTCSession,
|
||||
type Statistics,
|
||||
} from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { type Observable } from "rxjs";
|
||||
import {
|
||||
createRTCSlot,
|
||||
type EncryptionSystem,
|
||||
MembershipManagerError as RTCMembershipManagerError,
|
||||
type RTCSlot,
|
||||
} from "@element-hq/matrixrtc-sdk";
|
||||
|
||||
import { type JoinCallData } from "../widget";
|
||||
import { LobbyView } from "./LobbyView";
|
||||
@@ -39,7 +41,6 @@ import { findDeviceByName } from "../utils/media";
|
||||
import { ActiveCall } from "./InCallView";
|
||||
import { type MuteStates } from "../state/MuteStates";
|
||||
import { useMediaDevices } from "../MediaDevicesContext";
|
||||
import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships";
|
||||
import {
|
||||
saveKeyForRoom,
|
||||
useRoomEncryptionSystem,
|
||||
@@ -57,14 +58,11 @@ import {
|
||||
} from "./CallEventAudioRenderer";
|
||||
import { useLatest } from "../useLatest";
|
||||
import {
|
||||
ConnectionLostError,
|
||||
E2EENotSupportedError,
|
||||
ElementCallError,
|
||||
StickyEventsRequiredError,
|
||||
UnknownCallError,
|
||||
} from "../utils/errors.ts";
|
||||
import { GroupCallErrorBoundary } from "./GroupCallErrorBoundary.tsx";
|
||||
import { useTypedEventEmitter } from "../useEvents";
|
||||
import { muteAllAudio$ } from "../state/MuteAllAudioModel.ts";
|
||||
import { useAppBarTitle } from "../AppBar.tsx";
|
||||
import { useBehavior } from "../useBehavior.ts";
|
||||
@@ -73,6 +71,8 @@ import { useHostBridge } from "../HostBridge.ts";
|
||||
import { useMuteStates } from "../state/useMuteStates.ts";
|
||||
import { useLeaveToHome } from "../LeaveToHomeContext.ts";
|
||||
import { useLocalMedia } from "../useLocalMedia.ts";
|
||||
import { ObservableScope } from "../state/ObservableScope.ts";
|
||||
import { type CallNotificationWrapper } from "../state/CallViewModel/CallNotificationLifecycle.ts";
|
||||
|
||||
/**
|
||||
* If there already are this many participants in the call, we automatically mute
|
||||
@@ -153,8 +153,15 @@ interface Props {
|
||||
| "on"
|
||||
| "off"
|
||||
>;
|
||||
/** The call to join. */
|
||||
/** The call to join, which the RTC slot is built on. */
|
||||
rtcSession: MatrixRTCSession;
|
||||
/**
|
||||
* The call notifications the session sends with our join, so the call can
|
||||
* show it ringing: `observeSentCallNotification$(rtcSession)`.
|
||||
*/
|
||||
sentCallNotification$: Observable<CallNotificationWrapper>;
|
||||
/** The session's media key statistics, reported when the call ends. */
|
||||
statistics: Statistics;
|
||||
/**
|
||||
* Whether the user is signed in as a guest, and so should be offered the
|
||||
* chance to create an account when the call ends.
|
||||
@@ -185,18 +192,46 @@ interface Props {
|
||||
* whatever is hosting it — the standalone app's own shell, or an application
|
||||
* embedding Element Call as a component. Both render this.
|
||||
*/
|
||||
export const CallView: FC<Props> = (props): ReactNode => {
|
||||
export const CallView: FC<Props> = ({ rtcSession, ...props }): ReactNode => {
|
||||
// Whether the user is in the call is the call's own business, not its host's.
|
||||
// Held here rather than below so that it survives the mute state being
|
||||
// rebuilt.
|
||||
const [joined, setJoined] = useState(false);
|
||||
const muteStates = useMuteStates();
|
||||
const e2eeSystem = useRoomEncryptionSystem(props.room.roomId);
|
||||
|
||||
if (muteStates === null) return null;
|
||||
// One slot for every join of this call: leaving and joining again, to
|
||||
// reconnect or from the lobby, happens on the same one
|
||||
const [slot, setSlot] = useState<RTCSlot | null>(null);
|
||||
const { client, room } = props;
|
||||
useEffect(() => {
|
||||
const scope = new ObservableScope();
|
||||
setSlot(
|
||||
createRTCSlot(
|
||||
scope,
|
||||
client,
|
||||
room,
|
||||
{ encryptionSystem: e2eeSystem },
|
||||
rtcSession,
|
||||
),
|
||||
);
|
||||
return (): void => scope.end();
|
||||
}, [client, room, e2eeSystem, rtcSession]);
|
||||
|
||||
useEffect(() => {
|
||||
window.rtcSession = rtcSession;
|
||||
return (): void => {
|
||||
delete window.rtcSession;
|
||||
};
|
||||
}, [rtcSession]);
|
||||
|
||||
if (muteStates === null || slot === null) return null;
|
||||
|
||||
return (
|
||||
<LoadedCallView
|
||||
{...props}
|
||||
slot={slot}
|
||||
e2eeSystem={e2eeSystem}
|
||||
joined={joined}
|
||||
setJoined={setJoined}
|
||||
muteStates={muteStates}
|
||||
@@ -204,13 +239,80 @@ export const CallView: FC<Props> = (props): ReactNode => {
|
||||
);
|
||||
};
|
||||
|
||||
interface LoadedProps extends Props {
|
||||
// Here we do not pass the rtcSession anymore. This is a huge step!!
|
||||
// We only rely on our sdk abstraction (+ client and +room but only a
|
||||
// smaller list of callbacks.)
|
||||
interface LoadedProps extends Omit<Props, "rtcSession" | "client" | "room"> {
|
||||
// Narrower than `Props.client`: the `slot` already has what only it needs,
|
||||
// `getRTCTransports`, `delegateDelayedLeave`, `baseUrl`, `getSyncState` and
|
||||
// `ClientEvent.Sync`
|
||||
client: Pick<
|
||||
MatrixClient,
|
||||
| "getUserId"
|
||||
| "getDeviceId"
|
||||
| "getDomain"
|
||||
| "getOpenIdToken"
|
||||
| "getLivekitToken"
|
||||
| "sendEvent"
|
||||
| "redactEvent"
|
||||
| "decryptEventIfNeeded"
|
||||
| "getUser"
|
||||
| "setDisplayName"
|
||||
| "setAvatarUrl"
|
||||
| "uploadContent"
|
||||
| "doesServerSupportUnstableFeature"
|
||||
| "getCrypto"
|
||||
// `on`/`off`, to listen for `MatrixEventEvent.Decrypted` (reactions once
|
||||
// decrypted)
|
||||
| "on"
|
||||
| "off"
|
||||
>;
|
||||
// Narrower than `Props.room` only in what it listens for: the `slot` already
|
||||
// follows `RoomStateEvent.Events` for its status, and `RoomStateEvent.Members`
|
||||
// for its own members
|
||||
room: Pick<
|
||||
Room,
|
||||
| "roomId"
|
||||
| "name"
|
||||
| "getMxcAvatarUrl"
|
||||
| "getCanonicalAlias"
|
||||
| "currentState"
|
||||
| "getMembersWithMembership"
|
||||
| "_unstable_getStickyEvents"
|
||||
| "relations"
|
||||
// `on`/`off`, to listen for:
|
||||
// - `RoomEvent.Name` (room name)
|
||||
// - `RoomEvent.CurrentStateUpdated` (avatar and join rule hooks)
|
||||
// - `RoomStateEvent.Members` (call view model members)
|
||||
// - `RoomEvent.Timeline` and `RoomStickyEventsEvent.Update` (call notifications)
|
||||
// - `RoomEvent.Timeline`, `RoomEvent.Redaction` and
|
||||
// `RoomEvent.LocalEchoUpdated` (reactions and raised hands)
|
||||
| "on"
|
||||
| "off"
|
||||
>;
|
||||
slot: RTCSlot;
|
||||
e2eeSystem: EncryptionSystem;
|
||||
joined: boolean;
|
||||
setJoined: (value: boolean) => void;
|
||||
muteStates: MuteStates;
|
||||
}
|
||||
|
||||
/** {@link CallView}, once it has the mute state everything below needs. */
|
||||
/**
|
||||
* Whether our membership is live in the slot: seen in the room, and not taken
|
||||
* down by the membership manager stopping. Leaving the call only makes sense
|
||||
* then; an error before the join, or one that ended the membership, leaves
|
||||
* nothing to leave.
|
||||
*/
|
||||
function isInCall(slot: RTCSlot): boolean {
|
||||
const participation = slot.participation$.value;
|
||||
if (participation?.localMember$.value == null) return false;
|
||||
const state = participation.state$.value;
|
||||
return !(
|
||||
state.kind === "failed" && state.error instanceof RTCMembershipManagerError
|
||||
);
|
||||
}
|
||||
|
||||
/** {@link CallView}, once it has the slot and mute state everything below needs. */
|
||||
const LoadedCallView: FC<LoadedProps> = ({
|
||||
client,
|
||||
room,
|
||||
@@ -218,7 +320,10 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
confineToRoom,
|
||||
preload,
|
||||
skipLobby,
|
||||
rtcSession,
|
||||
slot,
|
||||
sentCallNotification$,
|
||||
statistics,
|
||||
e2eeSystem,
|
||||
joined,
|
||||
setJoined,
|
||||
muteStates,
|
||||
@@ -227,7 +332,7 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
const [externalError, setExternalError] = useState<ElementCallError | null>(
|
||||
null,
|
||||
);
|
||||
const memberships = useMatrixRTCSessionMemberships(rtcSession);
|
||||
const members = useBehavior(slot.members$);
|
||||
const rootElement = useRootElement();
|
||||
const hostBridge = useHostBridge();
|
||||
// A host that can close us is a host that decides when we stop existing, so
|
||||
@@ -246,7 +351,7 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
);
|
||||
// This should use `useEffectEvent` (only available in experimental versions)
|
||||
useEffect(() => {
|
||||
if (memberships.length >= MUTE_PARTICIPANT_COUNT)
|
||||
if (members.length >= MUTE_PARTICIPANT_COUNT)
|
||||
muteStates.audio.setEnabled$.value?.(false);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
@@ -268,39 +373,10 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
};
|
||||
}, [rootElement]);
|
||||
|
||||
useEffect(() => {
|
||||
window.rtcSession = rtcSession;
|
||||
return (): void => {
|
||||
delete window.rtcSession;
|
||||
};
|
||||
}, [rtcSession]);
|
||||
|
||||
// TODO move this into the callViewModel LocalMembership.ts
|
||||
// We might actually not need this at all. Since we get into fatalError on those errors already?
|
||||
useTypedEventEmitter(
|
||||
rtcSession,
|
||||
MatrixRTCSessionEvent.MembershipManagerError,
|
||||
(error) => {
|
||||
// When matrix_rtc_mode=matrix_2_0 is in effect but the homeserver does
|
||||
// not advertise MSC4354 (sticky events), the SDK throws an
|
||||
// `UnsupportedStickyEventsEndpointError`. The MembershipManager
|
||||
// scheduler wraps it and exposes the original via `.cause`.
|
||||
if (
|
||||
error instanceof Error &&
|
||||
error.cause instanceof UnsupportedStickyEventsEndpointError
|
||||
) {
|
||||
setExternalError(new StickyEventsRequiredError());
|
||||
} else {
|
||||
setExternalError(new ConnectionLostError());
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const { displayName, avatarUrl } = useProfile(client);
|
||||
const roomName = useRoomName(room);
|
||||
const roomAvatar = useRoomAvatar(room);
|
||||
const { returnToLobby, password: passwordFromUrl, header } = useUrlParams();
|
||||
const e2eeSystem = useRoomEncryptionSystem(room.roomId);
|
||||
|
||||
// Save the password once we start the groupCallView
|
||||
useEffect(() => {
|
||||
@@ -324,8 +400,8 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
|
||||
// Count each member only once, regardless of how many devices they use
|
||||
const participantCount = useMemo(
|
||||
() => new Set<string>(memberships.map((m) => m.userId!)).size,
|
||||
[memberships],
|
||||
() => new Set<string>(members.map((m) => m.userId)).size,
|
||||
[members],
|
||||
);
|
||||
|
||||
const mediaDevices = useMediaDevices();
|
||||
@@ -333,27 +409,24 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
// Opened by the lobby, published by the call: one capture for both
|
||||
const media = useLocalMedia();
|
||||
|
||||
const enterRTCSessionOrError = useCallback(
|
||||
async (rtcSession: MatrixRTCSession): Promise<void> => {
|
||||
try {
|
||||
setJoined(true);
|
||||
// TODO-MULTI-SFU what to do with error handling now that we don't use this function?
|
||||
// @BillCarsonFr
|
||||
} catch (e) {
|
||||
if (e instanceof ElementCallError) {
|
||||
setExternalError(e);
|
||||
} else {
|
||||
logger.error(`Unknown Error while entering RTC session`, e);
|
||||
const error = new UnknownCallError(
|
||||
e instanceof Error ? e : new Error("Unknown error", { cause: e }),
|
||||
);
|
||||
setExternalError(error);
|
||||
}
|
||||
const enterRTCSessionOrError = useCallback(async (): Promise<void> => {
|
||||
try {
|
||||
setJoined(true);
|
||||
// TODO-MULTI-SFU what to do with error handling now that we don't use this function?
|
||||
// @BillCarsonFr
|
||||
} catch (e) {
|
||||
if (e instanceof ElementCallError) {
|
||||
setExternalError(e);
|
||||
} else {
|
||||
logger.error(`Unknown Error while entering RTC session`, e);
|
||||
const error = new UnknownCallError(
|
||||
e instanceof Error ? e : new Error("Unknown error", { cause: e }),
|
||||
);
|
||||
setExternalError(error);
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
[setJoined],
|
||||
);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}, [setJoined]);
|
||||
|
||||
useEffect(() => {
|
||||
const defaultDeviceSetup = async ({
|
||||
@@ -416,7 +489,6 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
}
|
||||
}, [
|
||||
hostBridge,
|
||||
rtcSession,
|
||||
preload,
|
||||
skipLobby,
|
||||
mediaDevices,
|
||||
@@ -463,9 +535,9 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
const sendInstantly = hostControlsLifetime;
|
||||
PosthogAnalytics.instance.eventCallEnded.track(
|
||||
room.roomId,
|
||||
rtcSession.memberships.length,
|
||||
slot.members$.value.length,
|
||||
sendInstantly,
|
||||
rtcSession,
|
||||
statistics,
|
||||
);
|
||||
// Unfortunately the PostHog library provides no way to await the
|
||||
// tracking of an event, but we don't really want it to hold up our
|
||||
@@ -511,7 +583,8 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
hostBridge,
|
||||
hostControlsLifetime,
|
||||
room.roomId,
|
||||
rtcSession,
|
||||
slot,
|
||||
statistics,
|
||||
isPasswordlessUser,
|
||||
confineToRoom,
|
||||
returnToLobby,
|
||||
@@ -525,7 +598,7 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
hostBridge.setAlwaysOnScreen(true).catch((e) => {
|
||||
logger.error("Error calling setAlwaysOnScreen(true)", e);
|
||||
});
|
||||
}, [hostBridge, joined, rtcSession]);
|
||||
}, [hostBridge, joined]);
|
||||
|
||||
const joinRule = useJoinRule(room);
|
||||
|
||||
@@ -586,7 +659,8 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
<ActiveCall
|
||||
client={client}
|
||||
matrixInfo={matrixInfo}
|
||||
rtcSession={rtcSession as MatrixRTCSession}
|
||||
slot={slot}
|
||||
sentCallNotification$={sentCallNotification$}
|
||||
matrixRoom={room}
|
||||
onLeft={onLeft}
|
||||
media={media}
|
||||
@@ -626,7 +700,7 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
// Left, and the host decides what happens next:
|
||||
body = returnToLobby ? lobbyView : null;
|
||||
} else if (preload || skipLobby) {
|
||||
// The RTC session is not joined to yet (`isJoined`), but enterRTCSessionOrError should have been called.
|
||||
// Not in the call yet: waiting for the host to say when, or about to join
|
||||
body = null;
|
||||
} else {
|
||||
body = lobbyView;
|
||||
@@ -638,16 +712,16 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
setExternalError(null);
|
||||
if (action == "reconnect") {
|
||||
setLeft(false);
|
||||
await enterRTCSessionOrError(rtcSession).catch((e) => {
|
||||
await enterRTCSessionOrError().catch((e) => {
|
||||
logger.error("Error re-entering RTC session", e);
|
||||
});
|
||||
}
|
||||
}}
|
||||
onError={(_error) => {
|
||||
if (rtcSession.isJoined()) onLeft("error");
|
||||
if (isInCall(slot)) onLeft("error");
|
||||
// If there is an error we need to be dismissible again. This is done in
|
||||
// `onLeft` as well; we need it here explicitly in case
|
||||
// rtcSession.isJoined is false.
|
||||
// `onLeft` as well; we need it here explicitly in case we were not in
|
||||
// the call.
|
||||
void hostBridge.setAlwaysOnScreen(false);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
vi,
|
||||
} from "vitest";
|
||||
import { act, render, type RenderResult } from "@testing-library/react";
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { BehaviorSubject, NEVER } from "rxjs";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import { TooltipProvider } from "@vector-im/compound-web";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
@@ -25,7 +25,6 @@ import {
|
||||
mockMediaDevices,
|
||||
mockMuteStates,
|
||||
mockRtcMembership,
|
||||
type MockRTCSession,
|
||||
mockRTCSlot,
|
||||
mockRTCMember,
|
||||
testScope,
|
||||
@@ -44,7 +43,7 @@ import { ReactionsSenderProvider } from "../reactions/useReactionsSender";
|
||||
import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement";
|
||||
import { MemberAudioRenderer } from "../tracks/MemberAudioRenderer";
|
||||
import type * as MatrixRTCSdk from "@element-hq/matrixrtc-sdk";
|
||||
import { constant, type ObservableScope } from "@element-hq/matrixrtc-sdk";
|
||||
import { constant, type RTCSlot } from "@element-hq/matrixrtc-sdk";
|
||||
import { MediaDevicesContext } from "../MediaDevicesContext";
|
||||
import { type MediaDevices as ECMediaDevices } from "../state/MediaDevices";
|
||||
import { AppBar } from "../AppBar";
|
||||
@@ -73,12 +72,6 @@ vi.mock("../tile/GridTile");
|
||||
vi.mock("../tile/SpotlightTile");
|
||||
vi.mock("../e2ee/sharedKeyManagement");
|
||||
vi.mock("../tracks/MemberAudioRenderer");
|
||||
// ActiveCall builds the slot itself; the view is what these tests are about
|
||||
const createRTCSlotMock = vi.hoisted(() => vi.fn());
|
||||
vi.mock("@element-hq/matrixrtc-sdk", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof MatrixRTCSdk>()),
|
||||
createRTCSlot: createRTCSlotMock,
|
||||
}));
|
||||
vi.mock("react-use-measure", () => ({
|
||||
default: (): [() => void, object] => [(): void => {}, {}],
|
||||
}));
|
||||
@@ -98,25 +91,27 @@ const matrixInfo = {
|
||||
|
||||
let useRoomEncryptionSystemMock: MockedFunction<typeof useRoomEncryptionSystem>;
|
||||
|
||||
// The view is what these tests are about, so the slot is a stand-in
|
||||
function mockSlot(): RTCSlot {
|
||||
return mockRTCSlot(testScope(), {
|
||||
localMember$: constant(
|
||||
mockRTCMember(true, {
|
||||
membership: localRtcMember,
|
||||
tracks$: constant([]),
|
||||
}),
|
||||
),
|
||||
remoteMembers$: constant([
|
||||
mockRTCMember(false, {
|
||||
membership: aliceRtcMember,
|
||||
tracks$: constant([]),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
createRTCSlotMock.mockImplementation((scope: ObservableScope) =>
|
||||
mockRTCSlot(scope, {
|
||||
localMember$: constant(
|
||||
mockRTCMember(true, {
|
||||
membership: localRtcMember,
|
||||
tracks$: constant([]),
|
||||
}),
|
||||
),
|
||||
remoteMembers$: constant([
|
||||
mockRTCMember(false, {
|
||||
membership: aliceRtcMember,
|
||||
tracks$: constant([]),
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
// MemberAudioRenderer is tested separately.
|
||||
(
|
||||
MemberAudioRenderer as MockedFunction<typeof MemberAudioRenderer>
|
||||
@@ -132,12 +127,11 @@ interface CreateInCallViewArgs {
|
||||
withAppBar?: boolean;
|
||||
}
|
||||
function createInCallView(args: CreateInCallViewArgs = {}): RenderResult & {
|
||||
rtcSession: MockRTCSession;
|
||||
vm: CallViewModel;
|
||||
} {
|
||||
const mediaDevices = args.mediaDevices ?? mockMediaDevices({});
|
||||
const muteState = mockMuteStates();
|
||||
const { vm, footerVm, developerSettingsVm, rtcSession, matrixRoom, client } =
|
||||
const { vm, footerVm, developerSettingsVm, matrixRoom, client } =
|
||||
getBasicCallViewModelEnvironment(
|
||||
[local, alice],
|
||||
undefined,
|
||||
@@ -145,12 +139,9 @@ function createInCallView(args: CreateInCallViewArgs = {}): RenderResult & {
|
||||
args.callViewModelOptions,
|
||||
);
|
||||
|
||||
rtcSession.joined = true;
|
||||
|
||||
const inCallView = (
|
||||
<InCallView
|
||||
client={client}
|
||||
rtcSession={rtcSession.asMockedSession()}
|
||||
muteStates={muteState}
|
||||
vm={vm}
|
||||
footerVm={footerVm}
|
||||
@@ -174,7 +165,6 @@ function createInCallView(args: CreateInCallViewArgs = {}): RenderResult & {
|
||||
);
|
||||
return {
|
||||
...renderResult,
|
||||
rtcSession,
|
||||
vm,
|
||||
};
|
||||
}
|
||||
@@ -238,37 +228,53 @@ function fakeLocalMedia(): MatrixRTCSdk.LocalMedia {
|
||||
};
|
||||
}
|
||||
|
||||
function renderActiveCall(slot: RTCSlot): RenderResult {
|
||||
const { matrixRoom } = getBasicRTCSession([local, alice]);
|
||||
return render(
|
||||
<BrowserRouter>
|
||||
<MediaDevicesContext value={mockMediaDevices({})}>
|
||||
<BackgroundEffectsProvider
|
||||
effects={createAppBackgroundEffects(testScope())}
|
||||
>
|
||||
<TooltipProvider>
|
||||
<ActiveCall
|
||||
client={matrixRoom.client}
|
||||
slot={slot}
|
||||
sentCallNotification$={NEVER}
|
||||
matrixRoom={matrixRoom}
|
||||
muteStates={mockMuteStates()}
|
||||
matrixInfo={matrixInfo}
|
||||
onShareClick={null}
|
||||
e2eeSystem={{ kind: E2eeType.NONE }}
|
||||
media={fakeLocalMedia()}
|
||||
onLeft={(): void => {}}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
</BackgroundEffectsProvider>
|
||||
</MediaDevicesContext>
|
||||
</BrowserRouter>,
|
||||
);
|
||||
}
|
||||
|
||||
describe("ActiveCall", () => {
|
||||
it("creates the view models and renders the call", async () => {
|
||||
const mediaDevices = mockMediaDevices({});
|
||||
const { rtcSession, matrixRoom } = getBasicRTCSession([local, alice]);
|
||||
const { findByTestId } = render(
|
||||
<BrowserRouter>
|
||||
<MediaDevicesContext value={mediaDevices}>
|
||||
<BackgroundEffectsProvider
|
||||
effects={createAppBackgroundEffects(testScope())}
|
||||
>
|
||||
<TooltipProvider>
|
||||
<ActiveCall
|
||||
client={matrixRoom.client}
|
||||
rtcSession={rtcSession.asMockedSession()}
|
||||
matrixRoom={matrixRoom}
|
||||
muteStates={mockMuteStates()}
|
||||
matrixInfo={matrixInfo}
|
||||
onShareClick={null}
|
||||
e2eeSystem={{ kind: E2eeType.NONE }}
|
||||
media={fakeLocalMedia()}
|
||||
onLeft={(): void => {}}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
</BackgroundEffectsProvider>
|
||||
</MediaDevicesContext>
|
||||
</BrowserRouter>,
|
||||
);
|
||||
const { findByTestId } = renderActiveCall(mockSlot());
|
||||
// Rendering at all proves ActiveCall created all of its view models
|
||||
expect(await findByTestId("incall_leave")).toBeVisible();
|
||||
});
|
||||
|
||||
it("leaves the slot once gone, so that the next call can join it", async () => {
|
||||
const slot = mockSlot();
|
||||
const { findByTestId, unmount } = renderActiveCall(slot);
|
||||
await findByTestId("incall_leave");
|
||||
expect(slot.join).toHaveBeenCalled();
|
||||
const participation = slot.participation$.value!;
|
||||
expect(participation.leave).not.toHaveBeenCalled();
|
||||
|
||||
unmount();
|
||||
expect(participation.leave).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("lays the call out for the size of its root element", async () => {
|
||||
// jsdom has no layout and no ResizeObserver: the root reports whatever
|
||||
// size we say, and the observer notifies whenever we tell it to
|
||||
@@ -291,7 +297,7 @@ describe("ActiveCall", () => {
|
||||
|
||||
try {
|
||||
const mediaDevices = mockMediaDevices({});
|
||||
const { rtcSession, matrixRoom } = getBasicRTCSession([local, alice]);
|
||||
const { matrixRoom } = getBasicRTCSession([local, alice]);
|
||||
const { findByTestId, container } = render(
|
||||
<BrowserRouter>
|
||||
<RootElementProvider value={root}>
|
||||
@@ -302,7 +308,8 @@ describe("ActiveCall", () => {
|
||||
<TooltipProvider>
|
||||
<ActiveCall
|
||||
client={matrixRoom.client}
|
||||
rtcSession={rtcSession.asMockedSession()}
|
||||
slot={mockSlot()}
|
||||
sentCallNotification$={NEVER}
|
||||
matrixRoom={matrixRoom}
|
||||
muteStates={mockMuteStates()}
|
||||
matrixInfo={matrixInfo}
|
||||
|
||||
+27
-41
@@ -18,7 +18,7 @@ import {
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import useMeasure from "react-use-measure";
|
||||
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { type Observable } from "rxjs";
|
||||
import classNames from "classnames";
|
||||
import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -74,9 +74,8 @@ import { ReactionsAudioRenderer } from "./ReactionAudioRenderer";
|
||||
import { ReactionsOverlay } from "./ReactionsOverlay";
|
||||
import { CallEventAudioRenderer } from "./CallEventAudioRenderer";
|
||||
import {
|
||||
createRTCSlot,
|
||||
type RTCParticipationOptions,
|
||||
type RTCSlotOptions,
|
||||
type RTCSlot,
|
||||
constant,
|
||||
} from "@element-hq/matrixrtc-sdk";
|
||||
import {
|
||||
@@ -98,7 +97,10 @@ import {
|
||||
screenShareResolution,
|
||||
} from "../settings/settings";
|
||||
import { Config } from "../config/Config";
|
||||
import { createSentCallNotification$ } from "../state/CallViewModel/CallNotificationLifecycle.ts";
|
||||
import {
|
||||
type CallNotificationWrapper,
|
||||
createSentCallNotification$,
|
||||
} from "../state/CallViewModel/CallNotificationLifecycle.ts";
|
||||
import { ReactionsReader } from "../reactions/ReactionsReader";
|
||||
import { MemberAudioRenderer } from "../tracks/MemberAudioRenderer.tsx";
|
||||
import { muteAllAudio$ } from "../state/MuteAllAudioModel.ts";
|
||||
@@ -138,28 +140,21 @@ export interface ActiveCallProps extends Omit<
|
||||
> {
|
||||
client: Pick<
|
||||
MatrixClient,
|
||||
// Our own identity: RTC slot, call view model, footer, settings
|
||||
// Our own identity: call view model, footer, settings
|
||||
| "getUserId"
|
||||
| "getDeviceId"
|
||||
// Local transport discovery (RTC slot), developer settings
|
||||
// Developer settings: the local transport and authenticating with it,
|
||||
// `getOpenIdToken` for the JWT service flow, `getLivekitToken` for the
|
||||
// client-server API flow (MSC4195)
|
||||
| "getDomain"
|
||||
| "getRTCTransports"
|
||||
// LiveKit auth (RTC slot), developer settings: `getOpenIdToken` for the JWT
|
||||
// service flow, `getLivekitToken` for the client-server API flow (MSC4195)
|
||||
| "getOpenIdToken"
|
||||
| "getLivekitToken"
|
||||
// LiveKit delayed leave delegation and its probe (RTC slot)
|
||||
| "delegateDelayedLeave"
|
||||
| "baseUrl"
|
||||
// Homeserver connection (RTC slot): whether the client is syncing
|
||||
| "getSyncState"
|
||||
// Reactions and raised hands: sending, lowering, and decrypting
|
||||
| "sendEvent"
|
||||
| "redactEvent"
|
||||
| "decryptEventIfNeeded"
|
||||
// `on`/`off`, to listen for:
|
||||
// - `ClientEvent.Sync` (RTC slot homeserver connection)
|
||||
// - `MatrixEventEvent.Decrypted` (reactions once decrypted)
|
||||
// `on`/`off`, to listen for `MatrixEventEvent.Decrypted` (reactions once
|
||||
// decrypted)
|
||||
| "on"
|
||||
| "off"
|
||||
// Profile: display name and avatar, for the settings and the call ended view
|
||||
@@ -173,23 +168,26 @@ export interface ActiveCallProps extends Omit<
|
||||
>;
|
||||
matrixRoom: Pick<
|
||||
MatrixRoom,
|
||||
// RTC slot and call view model
|
||||
// Call view model and reactions
|
||||
| "roomId"
|
||||
// Joined and invited members, for the RTC slot and the call view model
|
||||
// Joined and invited members, for the call view model
|
||||
| "getMembersWithMembership"
|
||||
// Call notifications, for the call view model
|
||||
| "_unstable_getStickyEvents"
|
||||
// Raised hands already in the room, for the reactions reader
|
||||
| "relations"
|
||||
// `on`/`off`, to listen for:
|
||||
// - `RoomStateEvent.Events` (RTC slot status)
|
||||
// - `RoomStateEvent.Members` (RTC slot and call view model members)
|
||||
// - `RoomStateEvent.Members` (call view model members)
|
||||
// - `RoomEvent.Timeline` and `RoomStickyEventsEvent.Update` (call notifications)
|
||||
// - `RoomEvent.Timeline`, `RoomEvent.Redaction` and
|
||||
// `RoomEvent.LocalEchoUpdated` (reactions and raised hands)
|
||||
| "on"
|
||||
| "off"
|
||||
>;
|
||||
/** The slot to join; the call leaves it again when it ends. */
|
||||
slot: RTCSlot;
|
||||
/** The call notifications sent with our join, so the call can show it ringing. */
|
||||
sentCallNotification$: Observable<CallNotificationWrapper>;
|
||||
e2eeSystem: EncryptionSystem;
|
||||
/** The tracks the lobby opened, for the join to publish. */
|
||||
media: LocalMedia;
|
||||
@@ -217,16 +215,9 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
||||
useEffect(() => {
|
||||
rootLogger.info("START CALL VIEW SCOPE");
|
||||
const scope = new ObservableScope();
|
||||
const slot = createRTCSlot(
|
||||
scope,
|
||||
props.client,
|
||||
props.matrixRoom,
|
||||
rtcSlotOptions(props.e2eeSystem),
|
||||
props.rtcSession,
|
||||
);
|
||||
const reactionsReader = new ReactionsReader(
|
||||
scope,
|
||||
slot.members$,
|
||||
props.slot.members$,
|
||||
props.matrixRoom,
|
||||
props.client,
|
||||
);
|
||||
@@ -234,7 +225,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
||||
urlParams;
|
||||
|
||||
const capture = captureSettings();
|
||||
const rtcParticipation = slot.join({
|
||||
const rtcParticipation = props.slot.join({
|
||||
...rtcParticipationOptions(urlParams),
|
||||
// Without a lobby nothing was captured and the join captures itself
|
||||
publish:
|
||||
@@ -270,7 +261,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
||||
waitForCallPickup: waitForCallPickup && sendNotificationType === "ring",
|
||||
sentCallNotification$: createSentCallNotification$(
|
||||
scope,
|
||||
props.rtcSession,
|
||||
props.sentCallNotification$,
|
||||
),
|
||||
},
|
||||
);
|
||||
@@ -279,10 +270,13 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
||||
vm.leave$.pipe(scope.bind()).subscribe(props.onLeft);
|
||||
|
||||
return (): void => {
|
||||
// The slot outlives the call, and joins again only once this has left
|
||||
rtcParticipation.leave();
|
||||
scope.end();
|
||||
};
|
||||
}, [
|
||||
props.rtcSession,
|
||||
props.slot,
|
||||
props.sentCallNotification$,
|
||||
props.matrixRoom,
|
||||
props.muteStates,
|
||||
props.e2eeSystem,
|
||||
@@ -316,7 +310,6 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
||||
scope.end();
|
||||
};
|
||||
}, [
|
||||
props.rtcSession,
|
||||
props.matrixRoom,
|
||||
props.muteStates,
|
||||
props.e2eeSystem,
|
||||
@@ -354,7 +347,6 @@ export interface InCallViewProps {
|
||||
footerVm: ViewModel<FooterSnapshot>;
|
||||
developerSettingsVm: ViewModel<DeveloperSettingsSnapshot>;
|
||||
matrixInfo: MatrixInfo;
|
||||
rtcSession: MatrixRTCSession;
|
||||
matrixRoom: Pick<MatrixRoom, "roomId">;
|
||||
muteStates: MuteStates;
|
||||
onShareClick: (() => void) | null;
|
||||
@@ -867,17 +859,11 @@ export function captureSettings(): CaptureSettings {
|
||||
}
|
||||
|
||||
/**
|
||||
* What the client needs from Element Call's configuration, settings and URL:
|
||||
* What the join needs from Element Call's configuration, settings and URL:
|
||||
* the SDK reads none of them itself. What to publish depends on the mute
|
||||
* switches and the devices, so the caller adds that. Shared with the legacy
|
||||
* SDK bundle so that a widget built from it behaves like the app.
|
||||
*/
|
||||
export function rtcSlotOptions(
|
||||
encryptionSystem: EncryptionSystem,
|
||||
): RTCSlotOptions {
|
||||
return { encryptionSystem };
|
||||
}
|
||||
|
||||
export function rtcParticipationOptions(
|
||||
urlParams: ReturnType<typeof useUrlParams>,
|
||||
): Omit<RTCParticipationOptions, "publish"> {
|
||||
|
||||
@@ -118,6 +118,8 @@ export const RoomPage: FC = (): ReactNode => {
|
||||
client={client!}
|
||||
room={groupCallState.room}
|
||||
rtcSession={groupCallState.rtcSession}
|
||||
sentCallNotification$={groupCallState.sentCallNotification$}
|
||||
statistics={groupCallState.rtcSession.statistics}
|
||||
isPasswordlessUser={passwordlessUser}
|
||||
confineToRoom={confineToRoom}
|
||||
preload={preload}
|
||||
|
||||
@@ -33,13 +33,20 @@ import {
|
||||
CloseIcon,
|
||||
EndCallIcon,
|
||||
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
import { type Observable } from "rxjs";
|
||||
|
||||
import { useUrlParams } from "../UrlParams";
|
||||
import {
|
||||
type CallNotificationWrapper,
|
||||
observeSentCallNotification$,
|
||||
} from "../state/CallViewModel/CallNotificationLifecycle";
|
||||
|
||||
export type GroupCallLoaded = {
|
||||
kind: "loaded";
|
||||
room: Room;
|
||||
rtcSession: MatrixRTCSession;
|
||||
/** The call notifications `rtcSession` sends with our join. */
|
||||
sentCallNotification$: Observable<CallNotificationWrapper>;
|
||||
};
|
||||
|
||||
export type GroupCallLoadFailed = {
|
||||
@@ -371,7 +378,12 @@ export const useLoadGroupCall = (
|
||||
waitForClientSyncing()
|
||||
.then(fetchOrCreateGroupCall)
|
||||
.then(({ room, rtcSession }) =>
|
||||
setState({ kind: "loaded", room, rtcSession }),
|
||||
setState({
|
||||
kind: "loaded",
|
||||
room,
|
||||
rtcSession,
|
||||
sentCallNotification$: observeSentCallNotification$(rtcSession),
|
||||
}),
|
||||
)
|
||||
.then(observeMyMembership)
|
||||
.catch((error) => setState({ kind: "failed", error }));
|
||||
|
||||
@@ -63,15 +63,28 @@ export type CallNotificationWrapper = {
|
||||
event_id: string;
|
||||
} & IRTCNotificationContent;
|
||||
|
||||
/**
|
||||
* The call notifications the session sends with our join: what a host hands
|
||||
* the call as `sentCallNotification$`.
|
||||
*/
|
||||
export function observeSentCallNotification$(
|
||||
matrixRTCSession: Pick<MatrixRTCSession, "on" | "off">,
|
||||
): Observable<CallNotificationWrapper> {
|
||||
return fromEvent(
|
||||
matrixRTCSession,
|
||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||
(notification: CallNotificationWrapper) => notification,
|
||||
);
|
||||
}
|
||||
|
||||
export function createSentCallNotification$(
|
||||
scope: ObservableScope,
|
||||
matrixRTCSession: MatrixRTCSession,
|
||||
sentCallNotification$: Observable<CallNotificationWrapper>,
|
||||
): Behavior<CallNotificationWrapper | null> {
|
||||
const sentCallNotification$ = scope.behavior(
|
||||
fromEvent(matrixRTCSession, MatrixRTCSessionEvent.DidSendCallNotification),
|
||||
return scope.behavior<CallNotificationWrapper | null>(
|
||||
sentCallNotification$,
|
||||
null,
|
||||
) as Behavior<CallNotificationWrapper | null>;
|
||||
return sentCallNotification$;
|
||||
);
|
||||
}
|
||||
|
||||
export function createReceivedDecline$(
|
||||
|
||||
@@ -29,7 +29,10 @@ import {
|
||||
createCallViewModel$,
|
||||
type CallViewModelOptions,
|
||||
} from "./CallViewModel";
|
||||
import { createSentCallNotification$ } from "./CallNotificationLifecycle";
|
||||
import {
|
||||
createSentCallNotification$,
|
||||
observeSentCallNotification$,
|
||||
} from "./CallNotificationLifecycle";
|
||||
import {
|
||||
mockConfig,
|
||||
mockMatrixRoom,
|
||||
@@ -277,7 +280,7 @@ export function withCallViewModel(mode: MatrixRTCMode) {
|
||||
autoLeaveWhenOthersLeft: false,
|
||||
sentCallNotification$: createSentCallNotification$(
|
||||
scope,
|
||||
rtcSession.asMockedSession(),
|
||||
observeSentCallNotification$(rtcSession.asMockedSession()),
|
||||
),
|
||||
...options,
|
||||
},
|
||||
|
||||
@@ -35,26 +35,6 @@ export function useEventTarget<T extends Event>(
|
||||
}, [target, eventType, listener, options]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for registering a listener on a TypedEventEmitter.
|
||||
*/
|
||||
export function useTypedEventEmitter<
|
||||
Events extends string,
|
||||
Arguments extends ListenerMap<Events>,
|
||||
T extends Events,
|
||||
>(
|
||||
emitter: Pick<TypedEventEmitter<Events, Arguments>, "on" | "off">,
|
||||
eventType: T,
|
||||
listener: Listener<Events, Arguments, T>,
|
||||
): void {
|
||||
useEffect(() => {
|
||||
emitter.on(eventType, listener);
|
||||
return (): void => {
|
||||
emitter.off(eventType, listener);
|
||||
};
|
||||
}, [emitter, eventType, listener]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reactively tracks a value which is recalculated whenever the provided event
|
||||
* emitter emits an event. This is useful for bridging state from matrix-js-sdk
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
Copyright 2023, 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import {
|
||||
type CallMembership,
|
||||
type MatrixRTCSession,
|
||||
MatrixRTCSessionEvent,
|
||||
} from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { useCallback } from "react";
|
||||
|
||||
import { useTypedEventEmitterState } from "./useEvents";
|
||||
|
||||
export function useMatrixRTCSessionMemberships(
|
||||
rtcSession: MatrixRTCSession,
|
||||
): CallMembership[] {
|
||||
return useTypedEventEmitterState(
|
||||
rtcSession,
|
||||
MatrixRTCSessionEvent.MembershipsChanged,
|
||||
useCallback(() => rtcSession.memberships, [rtcSession]),
|
||||
);
|
||||
}
|
||||
+21
-15
@@ -7,6 +7,7 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { ConnectionError } from "livekit-client";
|
||||
import { UnsupportedStickyEventsEndpointError } from "matrix-js-sdk";
|
||||
import {
|
||||
ErrorCode as RTCErrorCode,
|
||||
FailToGetOpenIdToken as RTCFailToGetOpenIdToken,
|
||||
@@ -32,10 +33,10 @@ import {
|
||||
InsufficientCapacityError,
|
||||
LivekitConnectionError,
|
||||
MatrixRTCTransportMissingError,
|
||||
MembershipManagerError,
|
||||
NoMatrix2AuthorizationService,
|
||||
PeerConnectionTimeoutError,
|
||||
SFURoomCreationRestrictedError,
|
||||
StickyEventsRequiredError,
|
||||
UnknownCallError,
|
||||
} from "./errors";
|
||||
|
||||
@@ -43,17 +44,6 @@ import {
|
||||
// rather than the global one, so each needs to come out translated rather than
|
||||
// as a raw key.
|
||||
describe("localised errors", () => {
|
||||
test("MembershipManagerError describes the failure and keeps its cause", () => {
|
||||
const cause = new Error("the underlying problem");
|
||||
const error = new MembershipManagerError(cause);
|
||||
|
||||
expect(error.code).toBe(ErrorCode.INTERNAL_MEMBERSHIP_MANAGER);
|
||||
expect(error.category).toBe(ErrorCategory.SYSTEM_FAILURE);
|
||||
expect(error.localisedTitle).not.toContain("error.");
|
||||
expect(error.localisedMessage).not.toContain("error.");
|
||||
expect(error.cause).toBe(cause);
|
||||
});
|
||||
|
||||
test("NoMatrix2AuthorizationService is a configuration problem", () => {
|
||||
const cause = new Error("404");
|
||||
const error = new NoMatrix2AuthorizationService(cause);
|
||||
@@ -100,8 +90,22 @@ describe("fromMatrixRTCError", () => {
|
||||
{
|
||||
name: "membership manager failure",
|
||||
input: new RTCMembershipManagerError(cause),
|
||||
expected: MembershipManagerError,
|
||||
code: ErrorCode.INTERNAL_MEMBERSHIP_MANAGER,
|
||||
expected: ConnectionLostError,
|
||||
code: ErrorCode.CONNECTION_LOST_ERROR,
|
||||
},
|
||||
{
|
||||
name: "membership manager stopped by missing sticky events",
|
||||
// The membership manager's scheduler wraps the original error
|
||||
input: new RTCMembershipManagerError(
|
||||
new Error("The MembershipManager shut down", {
|
||||
cause: new UnsupportedStickyEventsEndpointError(
|
||||
"Server does not support the sticky events",
|
||||
"sendStickyEvent",
|
||||
),
|
||||
}),
|
||||
),
|
||||
expected: StickyEventsRequiredError,
|
||||
code: ErrorCode.STICKY_EVENTS_NOT_SUPPORTED,
|
||||
},
|
||||
{
|
||||
name: "OpenID token failure",
|
||||
@@ -169,7 +173,9 @@ describe("fromMatrixRTCError", () => {
|
||||
});
|
||||
|
||||
test("keeps the SDK error's cause for reporting", () => {
|
||||
const error = fromMatrixRTCError(new RTCMembershipManagerError(cause));
|
||||
const error = fromMatrixRTCError(
|
||||
new RTCNoMatrix2AuthorizationService(cause),
|
||||
);
|
||||
|
||||
expect(error.cause).toBe(cause);
|
||||
});
|
||||
|
||||
+5
-24
@@ -6,6 +6,7 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { type ConnectionError } from "livekit-client";
|
||||
import { UnsupportedStickyEventsEndpointError } from "matrix-js-sdk";
|
||||
import {
|
||||
ErrorCode as RTCErrorCode,
|
||||
FailToGetOpenIdToken as RTCFailToGetOpenIdToken,
|
||||
@@ -28,7 +29,6 @@ export enum ErrorCode {
|
||||
*/
|
||||
MISSING_MATRIX_RTC_TRANSPORT = "MISSING_MATRIX_RTC_TRANSPORT",
|
||||
CONNECTION_LOST_ERROR = "CONNECTION_LOST_ERROR",
|
||||
INTERNAL_MEMBERSHIP_MANAGER = "INTERNAL_MEMBERSHIP_MANAGER",
|
||||
FAILED_TO_START_LIVEKIT = "FAILED_TO_START_LIVEKIT",
|
||||
/** LiveKit indicates that the server has hit its track limits */
|
||||
INSUFFICIENT_CAPACITY_ERROR = "INSUFFICIENT_CAPACITY_ERROR",
|
||||
@@ -46,7 +46,6 @@ export enum ErrorCategory {
|
||||
NETWORK_CONNECTIVITY = "NETWORK_CONNECTIVITY",
|
||||
CLIENT_CONFIGURATION = "CLIENT_CONFIGURATION",
|
||||
UNKNOWN = "UNKNOWN",
|
||||
SYSTEM_FAILURE = "SYSTEM_FAILURE",
|
||||
// SYSTEM_FAILURE / FEDERATION_FAILURE ..
|
||||
}
|
||||
|
||||
@@ -117,27 +116,6 @@ export class ConnectionLostError extends ElementCallError {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error indicating a failure in the membership manager causing the join call
|
||||
* operation to fail.
|
||||
*/
|
||||
export class MembershipManagerError extends ElementCallError {
|
||||
/**
|
||||
* Creates an instance of MembershipManagerError.
|
||||
*
|
||||
* @param error - The underlying error that caused the membership manager failure.
|
||||
*/
|
||||
public constructor(error: Error) {
|
||||
super(
|
||||
i18n.t("error.membership_manager"),
|
||||
ErrorCode.INTERNAL_MEMBERSHIP_MANAGER,
|
||||
ErrorCategory.SYSTEM_FAILURE,
|
||||
i18n.t("error.membership_manager_description"),
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error indicating that this deployment pins `matrix_rtc_mode=matrix_2_0` in
|
||||
* config.json but the homeserver does not advertise MSC4354 (sticky events),
|
||||
@@ -314,7 +292,10 @@ export function fromMatrixRTCError(error: MatrixRTCError): ElementCallError {
|
||||
if (error instanceof RTCTransportMissingError)
|
||||
return new MatrixRTCTransportMissingError(error.domain);
|
||||
if (error instanceof RTCMembershipManagerError)
|
||||
return new MembershipManagerError(causeOf(error));
|
||||
// The membership manager wraps what made it stop
|
||||
return causeOf(error).cause instanceof UnsupportedStickyEventsEndpointError
|
||||
? new StickyEventsRequiredError()
|
||||
: new ConnectionLostError();
|
||||
if (error instanceof RTCFailToGetOpenIdToken)
|
||||
return new FailToGetOpenIdToken(causeOf(error));
|
||||
if (error instanceof RTCNoMatrix2AuthorizationService)
|
||||
|
||||
@@ -40,7 +40,10 @@ import { type RaisedHandInfo, type ReactionInfo } from "../reactions";
|
||||
import { constant } from "@element-hq/matrixrtc-sdk";
|
||||
import { map } from "rxjs";
|
||||
import { createCallFooterViewModel } from "../components/CallFooterViewModel";
|
||||
import { createSentCallNotification$ } from "../state/CallViewModel/CallNotificationLifecycle";
|
||||
import {
|
||||
createSentCallNotification$,
|
||||
observeSentCallNotification$,
|
||||
} from "../state/CallViewModel/CallNotificationLifecycle";
|
||||
import { HeaderStyle } from "../UrlParams";
|
||||
import { type FooterSnapshot } from "../components/CallFooter";
|
||||
import { type ViewModel } from "../state/ViewModel";
|
||||
@@ -234,7 +237,7 @@ export function getBasicCallViewModelEnvironment(
|
||||
{
|
||||
sentCallNotification$: createSentCallNotification$(
|
||||
scope,
|
||||
rtcSession.asMockedSession(),
|
||||
observeSentCallNotification$(rtcSession.asMockedSession()),
|
||||
),
|
||||
...callViewModelOptions,
|
||||
},
|
||||
|
||||
@@ -627,6 +627,13 @@ export class MockRTCSession extends TypedEventEmitter<
|
||||
return this.joined;
|
||||
}
|
||||
|
||||
public slotDescription = { application: "m.call", id: "ROOM" };
|
||||
/** The slot event's content; undefined while the room has none. */
|
||||
public rtcSlot: ReturnType<MatrixRTCSession["getRtcSlot"]> = undefined;
|
||||
public getRtcSlot(): ReturnType<MatrixRTCSession["getRtcSlot"]> {
|
||||
return this.rtcSlot;
|
||||
}
|
||||
|
||||
public isKeyRotationSuppressed = false;
|
||||
|
||||
public withMemberships(
|
||||
|
||||
Reference in new issue
Block a user