Files
element-call/src/room/LobbyView.tsx
Daniel Abramov f4f5c1ed31 Start using LiveKit SDK for media devices
This version is not supposed to properly work, this is a work in
progress.

Main changes:
* Completely removed the PTT logic (for simplicity, it could be
  introduced later).
* Abstracted away the work with the media devices.
* Defined confined interfaces of the affected components so that they
  only get the data that they need without importing Matris JS SDK or
  LiveKit SDK, so that we can exchange their "backend" at any time.
* Started using JS/TS SDK from LiveKit as well as their React SDK to
  define the state of the local media devices and local streams.
2023-05-30 15:21:22 +02:00

105 lines
3.1 KiB
TypeScript

/*
Copyright 2022 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
import { PressEvent } from "@react-types/shared";
import { Trans, useTranslation } from "react-i18next";
import styles from "./LobbyView.module.css";
import { Button, CopyButton } from "../button";
import { Header, LeftNav, RightNav, RoomHeaderInfo } from "../Header";
import { getRoomUrl } from "../matrix-utils";
import { UserMenuContainer } from "../UserMenuContainer";
import { Body, Link } from "../typography/Typography";
import { useLocationNavigation } from "../useLocationNavigation";
import { LocalMediaInfo, MatrixInfo, VideoPreview } from "./VideoPreview";
import { MediaDevicesState } from "./devices/useMediaDevices";
interface Props {
matrixInfo: MatrixInfo;
mediaDevices: MediaDevicesState;
localMedia: LocalMediaInfo;
onEnter: (e: PressEvent) => void;
isEmbedded: boolean;
hideHeader: boolean;
}
export function LobbyView(props: Props) {
const { t } = useTranslation();
useLocationNavigation();
const joinCallButtonRef = React.useRef<HTMLButtonElement>();
React.useEffect(() => {
if (joinCallButtonRef.current) {
joinCallButtonRef.current.focus();
}
}, [joinCallButtonRef]);
return (
<div className={styles.room}>
{!props.hideHeader && (
<Header>
<LeftNav>
<RoomHeaderInfo
roomName={props.matrixInfo.roomName}
avatarUrl={props.matrixInfo.avatarUrl}
/>
</LeftNav>
<RightNav>
<UserMenuContainer />
</RightNav>
</Header>
)}
<div className={styles.joinRoom}>
<div className={styles.joinRoomContent}>
<VideoPreview
matrixInfo={props.matrixInfo}
mediaDevices={props.mediaDevices}
localMediaInfo={props.localMedia}
/>
<Trans>
<Button
ref={joinCallButtonRef}
className={styles.copyButton}
size="lg"
onPress={props.onEnter}
>
Join call now
</Button>
<Body>Or</Body>
<CopyButton
variant="secondaryCopy"
value={getRoomUrl(props.matrixInfo.roomName)}
className={styles.copyButton}
copiedMessage={t("Call link copied")}
>
Copy call link and join later
</CopyButton>
</Trans>
</div>
{!props.isEmbedded && (
<Body className={styles.joinRoomFooter}>
<Link color="primary" to="/">
{t("Take me Home")}
</Link>
</Body>
)}
</div>
</div>
);
}