2022-05-04 17:09:48 +01:00
|
|
|
/*
|
2024-09-06 10:22:13 +02:00
|
|
|
Copyright 2022-2024 New Vector Ltd.
|
2022-05-04 17:09:48 +01:00
|
|
|
|
2025-02-18 17:59:58 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-06 10:22:13 +02:00
|
|
|
Please see LICENSE in the repository root for full details.
|
2022-05-04 17:09:48 +01:00
|
|
|
*/
|
|
|
|
|
|
2023-06-02 14:49:11 +02:00
|
|
|
import {
|
2023-06-26 13:48:41 -04:00
|
|
|
RoomAudioRenderer,
|
|
|
|
|
RoomContext,
|
2023-06-02 14:49:11 +02:00
|
|
|
useLocalParticipant,
|
|
|
|
|
} from "@livekit/components-react";
|
2024-12-11 09:27:55 +00:00
|
|
|
import { ConnectionState, type Room } from "livekit-client";
|
|
|
|
|
import { type MatrixClient } from "matrix-js-sdk/src/client";
|
2023-09-22 18:05:13 -04:00
|
|
|
import {
|
2024-12-11 09:27:55 +00:00
|
|
|
type FC,
|
|
|
|
|
type PointerEvent,
|
|
|
|
|
type PropsWithoutRef,
|
|
|
|
|
type TouchEvent,
|
2024-05-02 18:44:36 -04:00
|
|
|
forwardRef,
|
2023-09-22 18:05:13 -04:00
|
|
|
useCallback,
|
|
|
|
|
useEffect,
|
|
|
|
|
useMemo,
|
|
|
|
|
useRef,
|
|
|
|
|
useState,
|
2025-01-13 14:54:42 +00:00
|
|
|
type JSX,
|
2023-09-22 18:05:13 -04:00
|
|
|
} from "react";
|
2023-06-05 20:51:01 +02:00
|
|
|
import useMeasure from "react-use-measure";
|
2024-12-11 09:27:55 +00:00
|
|
|
import { type MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
|
2023-10-26 19:33:59 +02:00
|
|
|
import classNames from "classnames";
|
2024-11-06 04:43:27 -05:00
|
|
|
import { BehaviorSubject, map } from "rxjs";
|
|
|
|
|
import { useObservable, useObservableEagerState } from "observable-hooks";
|
2024-09-10 09:49:35 +02:00
|
|
|
import { logger } from "matrix-js-sdk/src/logger";
|
2022-08-02 00:46:16 +02:00
|
|
|
|
2023-09-27 19:06:10 -04:00
|
|
|
import LogoMark from "../icons/LogoMark.svg?react";
|
|
|
|
|
import LogoType from "../icons/LogoType.svg?react";
|
2022-09-09 02:10:45 -04:00
|
|
|
import type { IWidgetApiRequest } from "matrix-widget-api";
|
2022-01-05 15:06:51 -08:00
|
|
|
import {
|
2024-08-28 08:44:39 -04:00
|
|
|
EndCallButton,
|
2022-01-05 15:06:51 -08:00
|
|
|
MicButton,
|
|
|
|
|
VideoButton,
|
2024-08-28 08:44:39 -04:00
|
|
|
ShareScreenButton,
|
2023-05-05 11:44:35 +02:00
|
|
|
SettingsButton,
|
2024-11-08 17:36:40 +00:00
|
|
|
ReactionToggleButton,
|
2024-10-28 17:29:26 -04:00
|
|
|
SwitchCameraButton,
|
2022-01-05 15:06:51 -08:00
|
|
|
} from "../button";
|
2023-08-16 18:41:27 +01:00
|
|
|
import { Header, LeftNav, RightNav, RoomHeaderInfo } from "../Header";
|
2022-10-14 16:17:50 +02:00
|
|
|
import { useUrlParams } from "../UrlParams";
|
2023-06-05 20:51:01 +02:00
|
|
|
import { useCallViewKeyboardShortcuts } from "../useCallViewKeyboardShortcuts";
|
|
|
|
|
import { ElementWidgetActions, widget } from "../widget";
|
|
|
|
|
import styles from "./InCallView.module.css";
|
2024-05-02 18:44:36 -04:00
|
|
|
import { GridTile } from "../tile/GridTile";
|
2024-12-11 09:27:55 +00:00
|
|
|
import { type OTelGroupCallMembership } from "../otel/OTelGroupCallMembership";
|
2023-12-01 17:43:09 -05:00
|
|
|
import { SettingsModal, defaultSettingsTab } from "../settings/SettingsModal";
|
2023-05-22 15:30:29 -04:00
|
|
|
import { useRageshakeRequestModal } from "../settings/submit-rageshake";
|
|
|
|
|
import { RageshakeRequestModal } from "./RageshakeRequestModal";
|
2024-04-23 15:15:13 +02:00
|
|
|
import { useLiveKit } from "../livekit/useLiveKit";
|
2023-07-21 00:51:07 -04:00
|
|
|
import { useWakeLock } from "../useWakeLock";
|
2023-08-02 15:29:37 -04:00
|
|
|
import { useMergedRefs } from "../useMergedRefs";
|
2024-12-11 09:27:55 +00:00
|
|
|
import { type MuteStates } from "./MuteStates";
|
|
|
|
|
import { type MatrixInfo } from "./VideoPreview";
|
2023-09-27 15:17:04 -04:00
|
|
|
import { InviteButton } from "../button/InviteButton";
|
2023-09-08 15:39:10 -04:00
|
|
|
import { LayoutToggle } from "./LayoutToggle";
|
2024-12-11 09:27:55 +00:00
|
|
|
import { type ECConnectionState } from "../livekit/useECConnectionState";
|
2023-11-28 19:07:08 +01:00
|
|
|
import { useOpenIDSFU } from "../livekit/openIDSFU";
|
2024-12-11 09:27:55 +00:00
|
|
|
import {
|
|
|
|
|
CallViewModel,
|
|
|
|
|
type GridMode,
|
|
|
|
|
type Layout,
|
|
|
|
|
} from "../state/CallViewModel";
|
|
|
|
|
import { Grid, type TileProps } from "../grid/Grid";
|
2024-05-02 18:44:36 -04:00
|
|
|
import { useInitial } from "../useInitial";
|
|
|
|
|
import { SpotlightTile } from "../tile/SpotlightTile";
|
2024-12-11 09:27:55 +00:00
|
|
|
import { type EncryptionSystem } from "../e2ee/sharedKeyManagement";
|
2024-04-23 15:15:13 +02:00
|
|
|
import { E2eeType } from "../e2ee/e2eeType";
|
2024-05-17 16:38:00 -04:00
|
|
|
import { makeGridLayout } from "../grid/GridLayout";
|
2024-06-07 16:59:56 -04:00
|
|
|
import {
|
2024-12-11 09:27:55 +00:00
|
|
|
type CallLayoutOutputs,
|
2024-06-07 16:59:56 -04:00
|
|
|
defaultPipAlignment,
|
|
|
|
|
defaultSpotlightAlignment,
|
|
|
|
|
} from "../grid/CallLayout";
|
|
|
|
|
import { makeOneOnOneLayout } from "../grid/OneOnOneLayout";
|
2024-07-03 15:08:30 -04:00
|
|
|
import { makeSpotlightExpandedLayout } from "../grid/SpotlightExpandedLayout";
|
|
|
|
|
import { makeSpotlightLandscapeLayout } from "../grid/SpotlightLandscapeLayout";
|
|
|
|
|
import { makeSpotlightPortraitLayout } from "../grid/SpotlightPortraitLayout";
|
2024-12-11 09:27:55 +00:00
|
|
|
import { GridTileViewModel, type TileViewModel } from "../state/TileViewModel";
|
2024-12-19 15:54:28 +00:00
|
|
|
import {
|
|
|
|
|
ReactionsSenderProvider,
|
|
|
|
|
useReactionsSender,
|
|
|
|
|
} from "../reactions/useReactionsSender";
|
2024-11-08 17:36:40 +00:00
|
|
|
import { ReactionsAudioRenderer } from "./ReactionAudioRenderer";
|
2024-10-28 17:29:26 -04:00
|
|
|
import { useSwitchCamera } from "./useSwitchCamera";
|
2024-11-11 12:07:02 +00:00
|
|
|
import { ReactionsOverlay } from "./ReactionsOverlay";
|
2024-12-02 15:16:58 +00:00
|
|
|
import { CallEventAudioRenderer } from "./CallEventAudioRenderer";
|
2024-12-11 05:23:42 -05:00
|
|
|
import {
|
|
|
|
|
debugTileLayout as debugTileLayoutSetting,
|
|
|
|
|
useSetting,
|
|
|
|
|
} from "../settings/settings";
|
2024-12-19 15:54:28 +00:00
|
|
|
import { ReactionsReader } from "../reactions/ReactionsReader";
|
2025-02-28 12:04:49 +01:00
|
|
|
import { ConnectionLostError } from "../utils/errors.ts";
|
2022-01-05 15:06:51 -08:00
|
|
|
|
2022-07-03 10:36:16 -04:00
|
|
|
const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {});
|
2024-05-02 18:44:36 -04:00
|
|
|
|
2024-08-08 17:21:47 -04:00
|
|
|
const maxTapDurationMs = 400;
|
|
|
|
|
|
2023-11-28 19:07:08 +01:00
|
|
|
export interface ActiveCallProps
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
extends Omit<InCallViewProps, "vm" | "livekitRoom" | "connState"> {
|
2024-04-23 15:15:13 +02:00
|
|
|
e2eeSystem: EncryptionSystem;
|
2023-06-16 18:07:13 +02:00
|
|
|
}
|
|
|
|
|
|
2023-09-22 18:05:13 -04:00
|
|
|
export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
2023-11-28 19:07:08 +01:00
|
|
|
const sfuConfig = useOpenIDSFU(props.client, props.rtcSession);
|
|
|
|
|
const { livekitRoom, connState } = useLiveKit(
|
|
|
|
|
props.rtcSession,
|
|
|
|
|
props.muteStates,
|
|
|
|
|
sfuConfig,
|
2024-04-23 15:15:13 +02:00
|
|
|
props.e2eeSystem,
|
2023-11-28 19:07:08 +01:00
|
|
|
);
|
2024-12-17 04:01:56 +00:00
|
|
|
const connStateObservable$ = useObservable(
|
|
|
|
|
(inputs$) => inputs$.pipe(map(([connState]) => connState)),
|
2024-11-06 04:43:27 -05:00
|
|
|
[connState],
|
|
|
|
|
);
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
const [vm, setVm] = useState<CallViewModel | null>(null);
|
2023-11-28 19:07:08 +01:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
2024-06-04 11:20:25 -04:00
|
|
|
return (): void => {
|
2024-09-10 09:49:35 +02:00
|
|
|
livekitRoom?.disconnect().catch((e) => {
|
|
|
|
|
logger.error("Failed to disconnect from livekit room", e);
|
|
|
|
|
});
|
2023-11-28 19:07:08 +01:00
|
|
|
};
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, []);
|
|
|
|
|
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (livekitRoom !== undefined) {
|
2024-12-19 15:54:28 +00:00
|
|
|
const reactionsReader = new ReactionsReader(props.rtcSession);
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
const vm = new CallViewModel(
|
2024-12-06 12:28:37 +01:00
|
|
|
props.rtcSession,
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
livekitRoom,
|
2024-11-04 09:11:44 +00:00
|
|
|
props.e2eeSystem,
|
2024-12-17 04:01:56 +00:00
|
|
|
connStateObservable$,
|
2024-12-19 15:54:28 +00:00
|
|
|
reactionsReader.raisedHands$,
|
|
|
|
|
reactionsReader.reactions$,
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
);
|
|
|
|
|
setVm(vm);
|
2024-12-19 15:54:28 +00:00
|
|
|
return (): void => {
|
|
|
|
|
vm.destroy();
|
|
|
|
|
reactionsReader.destroy();
|
|
|
|
|
};
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
}
|
2024-12-17 04:01:56 +00:00
|
|
|
}, [props.rtcSession, livekitRoom, props.e2eeSystem, connStateObservable$]);
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
|
|
|
|
|
if (livekitRoom === undefined || vm === null) return null;
|
2023-06-30 16:43:28 +01:00
|
|
|
|
2023-06-26 13:48:41 -04:00
|
|
|
return (
|
2023-11-28 19:07:08 +01:00
|
|
|
<RoomContext.Provider value={livekitRoom}>
|
2024-12-19 15:54:28 +00:00
|
|
|
<ReactionsSenderProvider vm={vm} rtcSession={props.rtcSession}>
|
2024-11-04 08:54:13 -01:00
|
|
|
<InCallView
|
|
|
|
|
{...props}
|
|
|
|
|
vm={vm}
|
|
|
|
|
livekitRoom={livekitRoom}
|
|
|
|
|
connState={connState}
|
|
|
|
|
/>
|
2024-12-19 15:54:28 +00:00
|
|
|
</ReactionsSenderProvider>
|
2023-06-30 16:43:28 +01:00
|
|
|
</RoomContext.Provider>
|
2023-06-26 13:48:41 -04:00
|
|
|
);
|
2023-09-22 18:05:13 -04:00
|
|
|
};
|
2023-06-12 15:35:54 +02:00
|
|
|
|
2023-07-05 13:12:37 +01:00
|
|
|
export interface InCallViewProps {
|
2022-08-02 00:46:16 +02:00
|
|
|
client: MatrixClient;
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
vm: CallViewModel;
|
2023-09-08 15:39:10 -04:00
|
|
|
matrixInfo: MatrixInfo;
|
2023-08-16 18:41:27 +01:00
|
|
|
rtcSession: MatrixRTCSession;
|
2023-06-16 18:07:13 +02:00
|
|
|
livekitRoom: Room;
|
2023-08-02 15:29:37 -04:00
|
|
|
muteStates: MuteStates;
|
2023-09-27 18:12:04 -04:00
|
|
|
participantCount: number;
|
2025-02-26 17:20:30 +07:00
|
|
|
/** Function to call when the user explicitly ends the call */
|
|
|
|
|
onLeave: () => void;
|
2022-09-09 02:04:53 -04:00
|
|
|
hideHeader: boolean;
|
2023-06-30 16:43:28 +01:00
|
|
|
otelGroupCallMembership?: OTelGroupCallMembership;
|
2023-08-29 12:44:30 +01:00
|
|
|
connState: ECConnectionState;
|
2023-09-08 15:39:10 -04:00
|
|
|
onShareClick: (() => void) | null;
|
2022-08-02 00:46:16 +02:00
|
|
|
}
|
2022-08-08 20:01:58 +02:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
export const InCallView: FC<InCallViewProps> = ({
|
|
|
|
|
client,
|
Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed
By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.
* Hydrate the call view model in a less hacky way
This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.
* Add simple global controls to put the call in picture-in-picture mode
Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)
To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.
* Fix footer appearing in large PiP views
* Add a method for whether you can enter picture-in-picture mode
* Have the controls emit booleans directly
2024-08-27 07:47:20 -04:00
|
|
|
vm,
|
2024-05-16 15:23:10 -04:00
|
|
|
matrixInfo,
|
|
|
|
|
rtcSession,
|
|
|
|
|
livekitRoom,
|
|
|
|
|
muteStates,
|
|
|
|
|
participantCount,
|
|
|
|
|
onLeave,
|
|
|
|
|
hideHeader,
|
|
|
|
|
connState,
|
|
|
|
|
onShareClick,
|
|
|
|
|
}) => {
|
2024-12-19 15:54:28 +00:00
|
|
|
const { supportsReactions, sendReaction, toggleRaisedHand } =
|
|
|
|
|
useReactionsSender();
|
2024-11-04 08:54:13 -01:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
useWakeLock();
|
|
|
|
|
|
2025-02-26 17:20:30 +07:00
|
|
|
// annoyingly we don't get the disconnection reason this way,
|
|
|
|
|
// only by listening for the emitted event
|
|
|
|
|
if (connState === ConnectionState.Disconnected)
|
|
|
|
|
throw new ConnectionLostError();
|
2022-10-14 09:40:21 -04:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
const containerRef1 = useRef<HTMLDivElement | null>(null);
|
|
|
|
|
const [containerRef2, bounds] = useMeasure();
|
|
|
|
|
// Merge the refs so they can attach to the same element
|
|
|
|
|
const containerRef = useMergedRefs(containerRef1, containerRef2);
|
2023-06-02 14:49:11 +02:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
const { hideScreensharing, showControls } = useUrlParams();
|
|
|
|
|
|
|
|
|
|
const { isScreenShareEnabled, localParticipant } = useLocalParticipant({
|
|
|
|
|
room: livekitRoom,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const toggleMicrophone = useCallback(
|
|
|
|
|
() => muteStates.audio.setEnabled?.((e) => !e),
|
|
|
|
|
[muteStates],
|
|
|
|
|
);
|
|
|
|
|
const toggleCamera = useCallback(
|
|
|
|
|
() => muteStates.video.setEnabled?.((e) => !e),
|
|
|
|
|
[muteStates],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// This function incorrectly assumes that there is a camera and microphone, which is not always the case.
|
|
|
|
|
// TODO: Make sure that this module is resilient when it comes to camera/microphone availability!
|
|
|
|
|
useCallViewKeyboardShortcuts(
|
|
|
|
|
containerRef1,
|
|
|
|
|
toggleMicrophone,
|
|
|
|
|
toggleCamera,
|
|
|
|
|
(muted) => muteStates.audio.setEnabled?.(!muted),
|
2024-11-19 16:57:57 +00:00
|
|
|
(reaction) => void sendReaction(reaction),
|
|
|
|
|
() => void toggleRaisedHand(),
|
2024-05-16 15:23:10 -04:00
|
|
|
);
|
2023-01-12 17:31:19 +00:00
|
|
|
|
2024-12-17 04:01:56 +00:00
|
|
|
const windowMode = useObservableEagerState(vm.windowMode$);
|
|
|
|
|
const layout = useObservableEagerState(vm.layout$);
|
|
|
|
|
const tileStoreGeneration = useObservableEagerState(vm.tileStoreGeneration$);
|
2024-12-11 05:23:42 -05:00
|
|
|
const [debugTileLayout] = useSetting(debugTileLayoutSetting);
|
2024-12-17 04:01:56 +00:00
|
|
|
const gridMode = useObservableEagerState(vm.gridMode$);
|
|
|
|
|
const showHeader = useObservableEagerState(vm.showHeader$);
|
|
|
|
|
const showFooter = useObservableEagerState(vm.showFooter$);
|
|
|
|
|
const switchCamera = useSwitchCamera(vm.localVideo$);
|
2024-08-08 17:21:47 -04:00
|
|
|
|
|
|
|
|
// Ideally we could detect taps by listening for click events and checking
|
|
|
|
|
// that the pointerType of the event is "touch", but this isn't yet supported
|
|
|
|
|
// in Safari: https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event#browser_compatibility
|
|
|
|
|
// Instead we have to watch for sufficiently fast touch events.
|
|
|
|
|
const touchStart = useRef<number | null>(null);
|
|
|
|
|
const onTouchStart = useCallback(() => (touchStart.current = Date.now()), []);
|
|
|
|
|
const onTouchEnd = useCallback(() => {
|
|
|
|
|
const start = touchStart.current;
|
|
|
|
|
if (start !== null && Date.now() - start <= maxTapDurationMs)
|
|
|
|
|
vm.tapScreen();
|
|
|
|
|
touchStart.current = null;
|
|
|
|
|
}, [vm]);
|
|
|
|
|
const onTouchCancel = useCallback(() => (touchStart.current = null), []);
|
|
|
|
|
|
2024-11-08 10:23:19 -05:00
|
|
|
// We also need to tell the footer controls to prevent touch events from
|
|
|
|
|
// bubbling up, or else the footer will be dismissed before a click/change
|
|
|
|
|
// event can be registered on the control
|
|
|
|
|
const onControlsTouchEnd = useCallback(
|
|
|
|
|
(e: TouchEvent) => {
|
|
|
|
|
// Somehow applying pointer-events: none to the controls when the footer
|
|
|
|
|
// is hidden is not enough to stop clicks from happening as the footer
|
|
|
|
|
// becomes visible, so we check manually whether the footer is shown
|
|
|
|
|
if (showFooter) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
vm.tapControls();
|
|
|
|
|
} else {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
[vm, showFooter],
|
2024-08-08 17:21:47 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const onPointerMove = useCallback(
|
|
|
|
|
(e: PointerEvent) => {
|
|
|
|
|
if (e.pointerType === "mouse") vm.hoverScreen();
|
|
|
|
|
},
|
|
|
|
|
[vm],
|
|
|
|
|
);
|
|
|
|
|
const onPointerOut = useCallback(() => vm.unhoverScreen(), [vm]);
|
2024-05-02 18:44:36 -04:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
const [settingsModalOpen, setSettingsModalOpen] = useState(false);
|
|
|
|
|
const [settingsTab, setSettingsTab] = useState(defaultSettingsTab);
|
2024-05-02 18:44:36 -04:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
const openSettings = useCallback(
|
|
|
|
|
() => setSettingsModalOpen(true),
|
|
|
|
|
[setSettingsModalOpen],
|
|
|
|
|
);
|
|
|
|
|
const closeSettings = useCallback(
|
|
|
|
|
() => setSettingsModalOpen(false),
|
|
|
|
|
[setSettingsModalOpen],
|
|
|
|
|
);
|
2024-05-02 18:44:36 -04:00
|
|
|
|
2024-10-28 15:15:02 -04:00
|
|
|
const openProfile = useMemo(
|
|
|
|
|
() =>
|
|
|
|
|
// Profile settings are unavailable in widget mode
|
|
|
|
|
widget === null
|
|
|
|
|
? (): void => {
|
|
|
|
|
setSettingsTab("profile");
|
|
|
|
|
setSettingsModalOpen(true);
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
[setSettingsTab, setSettingsModalOpen],
|
|
|
|
|
);
|
2024-05-16 15:23:10 -04:00
|
|
|
|
|
|
|
|
const [headerRef, headerBounds] = useMeasure();
|
|
|
|
|
const [footerRef, footerBounds] = useMeasure();
|
2024-05-17 16:38:00 -04:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
const gridBounds = useMemo(
|
|
|
|
|
() => ({
|
2024-07-03 15:08:30 -04:00
|
|
|
width: bounds.width,
|
|
|
|
|
height:
|
|
|
|
|
bounds.height -
|
|
|
|
|
headerBounds.height -
|
|
|
|
|
(windowMode === "flat" ? 0 : footerBounds.height),
|
2024-05-16 15:23:10 -04:00
|
|
|
}),
|
|
|
|
|
[
|
2024-07-03 15:08:30 -04:00
|
|
|
bounds.width,
|
2024-05-16 15:23:10 -04:00
|
|
|
bounds.height,
|
|
|
|
|
headerBounds.height,
|
|
|
|
|
footerBounds.height,
|
2024-07-03 15:08:30 -04:00
|
|
|
windowMode,
|
2024-05-16 15:23:10 -04:00
|
|
|
],
|
|
|
|
|
);
|
2024-12-17 04:01:56 +00:00
|
|
|
const gridBoundsObservable$ = useObservable(
|
|
|
|
|
(inputs$) => inputs$.pipe(map(([gridBounds]) => gridBounds)),
|
2024-11-06 04:43:27 -05:00
|
|
|
[gridBounds],
|
|
|
|
|
);
|
2024-05-17 16:38:00 -04:00
|
|
|
|
2024-12-17 04:01:56 +00:00
|
|
|
const spotlightAlignment$ = useInitial(
|
2024-06-07 16:59:56 -04:00
|
|
|
() => new BehaviorSubject(defaultSpotlightAlignment),
|
|
|
|
|
);
|
2024-12-17 04:01:56 +00:00
|
|
|
const pipAlignment$ = useInitial(
|
2024-06-07 16:59:56 -04:00
|
|
|
() => new BehaviorSubject(defaultPipAlignment),
|
2024-05-16 15:23:10 -04:00
|
|
|
);
|
2024-05-17 16:38:00 -04:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
const setGridMode = useCallback(
|
2024-06-07 17:29:48 -04:00
|
|
|
(mode: GridMode) => vm.setGridMode(mode),
|
|
|
|
|
[vm],
|
2024-05-16 15:23:10 -04:00
|
|
|
);
|
2024-05-02 18:44:36 -04:00
|
|
|
|
2024-06-07 17:29:48 -04:00
|
|
|
useEffect(() => {
|
2024-09-10 09:49:35 +02:00
|
|
|
widget?.api.transport
|
|
|
|
|
.send(
|
|
|
|
|
gridMode === "grid"
|
|
|
|
|
? ElementWidgetActions.TileLayout
|
|
|
|
|
: ElementWidgetActions.SpotlightLayout,
|
|
|
|
|
{},
|
|
|
|
|
)
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
logger.error("Failed to send layout change to widget API", e);
|
|
|
|
|
});
|
2024-06-07 17:29:48 -04:00
|
|
|
}, [gridMode]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (widget) {
|
|
|
|
|
const onTileLayout = (ev: CustomEvent<IWidgetApiRequest>): void => {
|
|
|
|
|
setGridMode("grid");
|
|
|
|
|
widget!.api.transport.reply(ev.detail, {});
|
|
|
|
|
};
|
|
|
|
|
const onSpotlightLayout = (ev: CustomEvent<IWidgetApiRequest>): void => {
|
|
|
|
|
setGridMode("spotlight");
|
|
|
|
|
widget!.api.transport.reply(ev.detail, {});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
widget.lazyActions.on(ElementWidgetActions.TileLayout, onTileLayout);
|
|
|
|
|
widget.lazyActions.on(
|
|
|
|
|
ElementWidgetActions.SpotlightLayout,
|
|
|
|
|
onSpotlightLayout,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (): void => {
|
|
|
|
|
widget!.lazyActions.off(ElementWidgetActions.TileLayout, onTileLayout);
|
|
|
|
|
widget!.lazyActions.off(
|
|
|
|
|
ElementWidgetActions.SpotlightLayout,
|
|
|
|
|
onSpotlightLayout,
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}, [setGridMode]);
|
|
|
|
|
|
2024-05-30 13:06:24 -04:00
|
|
|
const Tile = useMemo(
|
2024-05-16 15:23:10 -04:00
|
|
|
() =>
|
2024-05-30 13:06:24 -04:00
|
|
|
forwardRef<
|
|
|
|
|
HTMLDivElement,
|
2024-11-06 04:36:48 -05:00
|
|
|
PropsWithoutRef<TileProps<TileViewModel, HTMLDivElement>>
|
2024-05-30 13:06:24 -04:00
|
|
|
>(function Tile(
|
|
|
|
|
{ className, style, targetWidth, targetHeight, model },
|
|
|
|
|
ref,
|
|
|
|
|
) {
|
2024-12-17 04:01:56 +00:00
|
|
|
const spotlightExpanded = useObservableEagerState(
|
|
|
|
|
vm.spotlightExpanded$,
|
|
|
|
|
);
|
2024-08-01 13:49:09 -04:00
|
|
|
const onToggleExpanded = useObservableEagerState(
|
2024-12-17 04:01:56 +00:00
|
|
|
vm.toggleSpotlightExpanded$,
|
2024-07-26 06:57:49 -04:00
|
|
|
);
|
2024-05-30 13:06:24 -04:00
|
|
|
const showSpeakingIndicatorsValue = useObservableEagerState(
|
2024-12-17 04:01:56 +00:00
|
|
|
vm.showSpeakingIndicators$,
|
2024-05-30 13:06:24 -04:00
|
|
|
);
|
|
|
|
|
const showSpotlightIndicatorsValue = useObservableEagerState(
|
2024-12-17 04:01:56 +00:00
|
|
|
vm.showSpotlightIndicators$,
|
2024-05-30 13:06:24 -04:00
|
|
|
);
|
|
|
|
|
|
2024-11-06 04:36:48 -05:00
|
|
|
return model instanceof GridTileViewModel ? (
|
2024-05-30 13:06:24 -04:00
|
|
|
<GridTile
|
|
|
|
|
ref={ref}
|
2024-11-06 04:36:48 -05:00
|
|
|
vm={model}
|
2024-05-30 13:06:24 -04:00
|
|
|
onOpenProfile={openProfile}
|
|
|
|
|
targetWidth={targetWidth}
|
|
|
|
|
targetHeight={targetHeight}
|
|
|
|
|
className={classNames(className, styles.tile)}
|
|
|
|
|
style={style}
|
|
|
|
|
showSpeakingIndicators={showSpeakingIndicatorsValue}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<SpotlightTile
|
|
|
|
|
ref={ref}
|
2024-11-06 04:36:48 -05:00
|
|
|
vm={model}
|
2024-07-03 15:08:30 -04:00
|
|
|
expanded={spotlightExpanded}
|
2024-07-26 06:57:49 -04:00
|
|
|
onToggleExpanded={onToggleExpanded}
|
2024-05-30 13:06:24 -04:00
|
|
|
targetWidth={targetWidth}
|
|
|
|
|
targetHeight={targetHeight}
|
|
|
|
|
showIndicators={showSpotlightIndicatorsValue}
|
|
|
|
|
className={classNames(className, styles.tile)}
|
|
|
|
|
style={style}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}),
|
2024-07-26 06:57:49 -04:00
|
|
|
[vm, openProfile],
|
2024-05-16 15:23:10 -04:00
|
|
|
);
|
2024-05-30 13:06:24 -04:00
|
|
|
|
2024-07-03 15:08:30 -04:00
|
|
|
const layouts = useMemo(() => {
|
|
|
|
|
const inputs = {
|
2024-12-17 04:01:56 +00:00
|
|
|
minBounds$: gridBoundsObservable$,
|
|
|
|
|
spotlightAlignment$,
|
|
|
|
|
pipAlignment$,
|
2024-07-03 15:08:30 -04:00
|
|
|
};
|
|
|
|
|
return {
|
|
|
|
|
grid: makeGridLayout(inputs),
|
2024-07-18 11:24:18 -04:00
|
|
|
"spotlight-landscape": makeSpotlightLandscapeLayout(inputs),
|
|
|
|
|
"spotlight-portrait": makeSpotlightPortraitLayout(inputs),
|
|
|
|
|
"spotlight-expanded": makeSpotlightExpandedLayout(inputs),
|
2024-07-03 15:08:30 -04:00
|
|
|
"one-on-one": makeOneOnOneLayout(inputs),
|
|
|
|
|
};
|
2024-12-17 04:01:56 +00:00
|
|
|
}, [gridBoundsObservable$, spotlightAlignment$, pipAlignment$]);
|
2024-07-03 15:08:30 -04:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
const renderContent = (): JSX.Element => {
|
2024-07-03 15:08:30 -04:00
|
|
|
if (layout.type === "pip") {
|
|
|
|
|
return (
|
|
|
|
|
<SpotlightTile
|
|
|
|
|
className={classNames(styles.tile, styles.maximised)}
|
2024-11-06 04:36:48 -05:00
|
|
|
vm={layout.spotlight}
|
2024-07-03 15:08:30 -04:00
|
|
|
expanded
|
|
|
|
|
onToggleExpanded={null}
|
|
|
|
|
targetWidth={gridBounds.height}
|
|
|
|
|
targetHeight={gridBounds.width}
|
|
|
|
|
showIndicators={false}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2024-05-16 15:23:10 -04:00
|
|
|
}
|
2022-12-13 18:20:13 -05:00
|
|
|
|
2024-07-03 15:08:30 -04:00
|
|
|
const layers = layouts[layout.type] as CallLayoutOutputs<Layout>;
|
|
|
|
|
const fixedGrid = (
|
|
|
|
|
<Grid
|
|
|
|
|
key="fixed"
|
|
|
|
|
className={styles.fixedGrid}
|
|
|
|
|
style={{
|
|
|
|
|
insetBlockStart: headerBounds.bottom,
|
|
|
|
|
height: gridBounds.height,
|
|
|
|
|
}}
|
|
|
|
|
model={layout}
|
|
|
|
|
Layout={layers.fixed}
|
|
|
|
|
Tile={Tile}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
const scrollingGrid = (
|
|
|
|
|
<Grid
|
|
|
|
|
key="scrolling"
|
|
|
|
|
className={styles.scrollingGrid}
|
|
|
|
|
model={layout}
|
|
|
|
|
Layout={layers.scrolling}
|
|
|
|
|
Tile={Tile}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
// The grid tiles go *under* the spotlight in the portrait layout, but
|
|
|
|
|
// *over* the spotlight in the expanded layout
|
2024-07-18 11:24:18 -04:00
|
|
|
return layout.type === "spotlight-expanded" ? (
|
2024-06-07 17:29:48 -04:00
|
|
|
<>
|
2024-07-03 15:08:30 -04:00
|
|
|
{fixedGrid}
|
|
|
|
|
{scrollingGrid}
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
{scrollingGrid}
|
|
|
|
|
{fixedGrid}
|
2024-06-07 17:29:48 -04:00
|
|
|
</>
|
|
|
|
|
);
|
2024-05-16 15:23:10 -04:00
|
|
|
};
|
2023-09-04 12:46:06 +01:00
|
|
|
|
2024-05-16 15:23:10 -04:00
|
|
|
const rageshakeRequestModalProps = useRageshakeRequestModal(
|
|
|
|
|
rtcSession.room.roomId,
|
|
|
|
|
);
|
2023-11-30 22:59:19 -05:00
|
|
|
|
2024-09-10 09:49:35 +02:00
|
|
|
const toggleScreensharing = useCallback(() => {
|
|
|
|
|
localParticipant
|
|
|
|
|
.setScreenShareEnabled(!isScreenShareEnabled, {
|
|
|
|
|
audio: true,
|
|
|
|
|
selfBrowserSurface: "include",
|
|
|
|
|
surfaceSwitching: "include",
|
|
|
|
|
systemAudio: "include",
|
|
|
|
|
})
|
|
|
|
|
.catch(logger.error);
|
2024-07-03 15:08:30 -04:00
|
|
|
}, [localParticipant, isScreenShareEnabled]);
|
2024-05-16 15:23:10 -04:00
|
|
|
|
2024-11-08 12:16:59 -05:00
|
|
|
const buttons: JSX.Element[] = [];
|
|
|
|
|
|
|
|
|
|
buttons.push(
|
|
|
|
|
<MicButton
|
|
|
|
|
key="audio"
|
|
|
|
|
muted={!muteStates.audio.enabled}
|
|
|
|
|
onClick={toggleMicrophone}
|
2024-11-08 10:23:19 -05:00
|
|
|
onTouchEnd={onControlsTouchEnd}
|
2024-11-08 12:16:59 -05:00
|
|
|
disabled={muteStates.audio.setEnabled === null}
|
|
|
|
|
data-testid="incall_mute"
|
|
|
|
|
/>,
|
|
|
|
|
<VideoButton
|
|
|
|
|
key="video"
|
|
|
|
|
muted={!muteStates.video.enabled}
|
|
|
|
|
onClick={toggleCamera}
|
2024-11-08 10:23:19 -05:00
|
|
|
onTouchEnd={onControlsTouchEnd}
|
2024-11-08 12:16:59 -05:00
|
|
|
disabled={muteStates.video.setEnabled === null}
|
|
|
|
|
data-testid="incall_videomute"
|
|
|
|
|
/>,
|
|
|
|
|
);
|
|
|
|
|
if (switchCamera !== null)
|
2024-05-16 15:23:10 -04:00
|
|
|
buttons.push(
|
2024-11-08 12:16:59 -05:00
|
|
|
<SwitchCameraButton
|
|
|
|
|
key="switch_camera"
|
|
|
|
|
className={styles.switchCamera}
|
|
|
|
|
onClick={switchCamera}
|
2024-11-08 10:23:19 -05:00
|
|
|
onTouchEnd={onControlsTouchEnd}
|
2024-05-16 15:23:10 -04:00
|
|
|
/>,
|
|
|
|
|
);
|
2024-11-08 12:16:59 -05:00
|
|
|
if (canScreenshare && !hideScreensharing) {
|
2024-05-16 15:23:10 -04:00
|
|
|
buttons.push(
|
2024-11-08 12:16:59 -05:00
|
|
|
<ShareScreenButton
|
|
|
|
|
key="share_screen"
|
|
|
|
|
className={styles.shareScreen}
|
|
|
|
|
enabled={isScreenShareEnabled}
|
|
|
|
|
onClick={toggleScreensharing}
|
2024-11-08 10:23:19 -05:00
|
|
|
onTouchEnd={onControlsTouchEnd}
|
2024-11-08 12:16:59 -05:00
|
|
|
data-testid="incall_screenshare"
|
2024-05-16 15:23:10 -04:00
|
|
|
/>,
|
|
|
|
|
);
|
2024-11-08 12:16:59 -05:00
|
|
|
}
|
|
|
|
|
if (supportsReactions) {
|
|
|
|
|
buttons.push(
|
2024-11-08 12:45:09 -05:00
|
|
|
<ReactionToggleButton
|
2024-12-19 15:54:28 +00:00
|
|
|
vm={vm}
|
2024-11-08 12:16:59 -05:00
|
|
|
key="raise_hand"
|
|
|
|
|
className={styles.raiseHand}
|
2024-12-19 15:54:28 +00:00
|
|
|
identifier={`${client.getUserId()}:${client.getDeviceId()}`}
|
2024-11-08 10:23:19 -05:00
|
|
|
onTouchEnd={onControlsTouchEnd}
|
2024-11-08 12:16:59 -05:00
|
|
|
/>,
|
2023-11-30 22:59:19 -05:00
|
|
|
);
|
2024-05-16 15:23:10 -04:00
|
|
|
}
|
2024-11-08 12:16:59 -05:00
|
|
|
if (layout.type !== "pip")
|
2024-11-08 10:23:19 -05:00
|
|
|
buttons.push(
|
|
|
|
|
<SettingsButton
|
|
|
|
|
key="settings"
|
|
|
|
|
onClick={openSettings}
|
|
|
|
|
onTouchEnd={onControlsTouchEnd}
|
|
|
|
|
/>,
|
|
|
|
|
);
|
2024-11-08 12:16:59 -05:00
|
|
|
|
|
|
|
|
buttons.push(
|
|
|
|
|
<EndCallButton
|
|
|
|
|
key="end_call"
|
|
|
|
|
onClick={function (): void {
|
|
|
|
|
onLeave();
|
|
|
|
|
}}
|
2024-11-08 10:23:19 -05:00
|
|
|
onTouchEnd={onControlsTouchEnd}
|
2024-11-08 12:16:59 -05:00
|
|
|
data-testid="incall_leave"
|
|
|
|
|
/>,
|
|
|
|
|
);
|
|
|
|
|
const footer = (
|
|
|
|
|
<div
|
|
|
|
|
ref={footerRef}
|
|
|
|
|
className={classNames(styles.footer, {
|
|
|
|
|
[styles.overlay]: windowMode === "flat",
|
|
|
|
|
[styles.hidden]: !showFooter || (!showControls && hideHeader),
|
|
|
|
|
})}
|
|
|
|
|
>
|
|
|
|
|
{!hideHeader && (
|
|
|
|
|
<div className={styles.logo}>
|
|
|
|
|
<LogoMark width={24} height={24} aria-hidden />
|
|
|
|
|
<LogoType
|
|
|
|
|
width={80}
|
|
|
|
|
height={11}
|
|
|
|
|
aria-label={import.meta.env.VITE_PRODUCT_NAME || "Element Call"}
|
|
|
|
|
/>
|
2024-12-11 05:23:42 -05:00
|
|
|
{/* Don't mind this odd placement, it's just a little debug label */}
|
|
|
|
|
{debugTileLayout
|
|
|
|
|
? `Tiles generation: ${tileStoreGeneration}`
|
|
|
|
|
: undefined}
|
2024-11-08 12:16:59 -05:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{showControls && <div className={styles.buttons}>{buttons}</div>}
|
|
|
|
|
{showControls && (
|
|
|
|
|
<LayoutToggle
|
|
|
|
|
className={styles.layout}
|
|
|
|
|
layout={gridMode}
|
|
|
|
|
setLayout={setGridMode}
|
2024-11-08 10:23:19 -05:00
|
|
|
onTouchEnd={onControlsTouchEnd}
|
2024-11-08 12:16:59 -05:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2024-05-16 15:23:10 -04:00
|
|
|
|
|
|
|
|
return (
|
2024-08-08 17:21:47 -04:00
|
|
|
<div
|
|
|
|
|
className={styles.inRoom}
|
|
|
|
|
ref={containerRef}
|
|
|
|
|
onTouchStart={onTouchStart}
|
|
|
|
|
onTouchEnd={onTouchEnd}
|
|
|
|
|
onTouchCancel={onTouchCancel}
|
|
|
|
|
onPointerMove={onPointerMove}
|
|
|
|
|
onPointerOut={onPointerOut}
|
|
|
|
|
>
|
|
|
|
|
{showHeader &&
|
2024-08-01 16:25:33 -04:00
|
|
|
(hideHeader ? (
|
|
|
|
|
// Cosmetic header to fill out space while still affecting the bounds
|
|
|
|
|
// of the grid
|
|
|
|
|
<div
|
|
|
|
|
className={classNames(styles.header, styles.filler)}
|
|
|
|
|
ref={headerRef}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<Header className={styles.header} ref={headerRef}>
|
|
|
|
|
<LeftNav>
|
|
|
|
|
<RoomHeaderInfo
|
|
|
|
|
id={matrixInfo.roomId}
|
|
|
|
|
name={matrixInfo.roomName}
|
|
|
|
|
avatarUrl={matrixInfo.roomAvatar}
|
|
|
|
|
encrypted={matrixInfo.e2eeSystem.kind !== E2eeType.NONE}
|
|
|
|
|
participantCount={participantCount}
|
|
|
|
|
/>
|
|
|
|
|
</LeftNav>
|
|
|
|
|
<RightNav>
|
2024-11-08 12:16:59 -05:00
|
|
|
{showControls && onShareClick !== null && (
|
|
|
|
|
<InviteButton
|
|
|
|
|
className={styles.invite}
|
|
|
|
|
onClick={onShareClick}
|
|
|
|
|
/>
|
2024-08-01 16:25:33 -04:00
|
|
|
)}
|
|
|
|
|
</RightNav>
|
|
|
|
|
</Header>
|
|
|
|
|
))}
|
2024-05-16 15:23:10 -04:00
|
|
|
<RoomAudioRenderer />
|
|
|
|
|
{renderContent()}
|
2024-12-02 15:16:58 +00:00
|
|
|
<CallEventAudioRenderer vm={vm} />
|
2024-12-19 15:54:28 +00:00
|
|
|
<ReactionsAudioRenderer vm={vm} />
|
|
|
|
|
<ReactionsOverlay vm={vm} />
|
2024-05-16 15:23:10 -04:00
|
|
|
{footer}
|
2024-11-08 12:16:59 -05:00
|
|
|
{layout.type !== "pip" && (
|
|
|
|
|
<>
|
|
|
|
|
<RageshakeRequestModal {...rageshakeRequestModalProps} />
|
|
|
|
|
<SettingsModal
|
|
|
|
|
client={client}
|
|
|
|
|
roomId={rtcSession.room.roomId}
|
|
|
|
|
open={settingsModalOpen}
|
|
|
|
|
onDismiss={closeSettings}
|
|
|
|
|
tab={settingsTab}
|
|
|
|
|
onTabChange={setSettingsTab}
|
2025-02-10 17:22:19 +00:00
|
|
|
livekitRoom={livekitRoom}
|
2024-11-08 12:16:59 -05:00
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2024-05-16 15:23:10 -04:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|