2022-05-04 17:09:48 +01:00
|
|
|
/*
|
2023-01-03 16:55:26 +00:00
|
|
|
Copyright 2022 New Vector Ltd
|
2022-05-04 17:09:48 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2023-05-26 20:41:32 +02:00
|
|
|
import React from "react";
|
2022-08-02 00:46:16 +02:00
|
|
|
import { PressEvent } from "@react-types/shared";
|
2022-10-24 10:17:12 -04:00
|
|
|
import { Trans, useTranslation } from "react-i18next";
|
2022-08-02 00:46:16 +02:00
|
|
|
|
2022-01-05 13:09:12 -08:00
|
|
|
import styles from "./LobbyView.module.css";
|
2022-04-27 15:18:55 -07:00
|
|
|
import { Button, CopyButton } from "../button";
|
2022-01-05 13:09:12 -08:00
|
|
|
import { Header, LeftNav, RightNav, RoomHeaderInfo } from "../Header";
|
2022-01-05 17:19:03 -08:00
|
|
|
import { getRoomUrl } from "../matrix-utils";
|
2022-01-05 13:09:12 -08:00
|
|
|
import { UserMenuContainer } from "../UserMenuContainer";
|
|
|
|
import { Body, Link } from "../typography/Typography";
|
2022-02-03 16:56:13 -08:00
|
|
|
import { useLocationNavigation } from "../useLocationNavigation";
|
2023-05-26 20:41:32 +02:00
|
|
|
import { LocalMediaInfo, MatrixInfo, VideoPreview } from "./VideoPreview";
|
2023-05-30 20:56:25 +02:00
|
|
|
import { MediaDevicesState } from "../settings/mediaDevices";
|
2022-01-05 13:09:12 -08:00
|
|
|
|
2022-08-02 00:46:16 +02:00
|
|
|
interface Props {
|
2023-05-26 20:41:32 +02:00
|
|
|
matrixInfo: MatrixInfo;
|
|
|
|
mediaDevices: MediaDevicesState;
|
|
|
|
localMedia: LocalMediaInfo;
|
|
|
|
|
2022-08-02 00:46:16 +02:00
|
|
|
onEnter: (e: PressEvent) => void;
|
|
|
|
isEmbedded: boolean;
|
2022-09-09 02:04:53 -04:00
|
|
|
hideHeader: boolean;
|
2022-08-02 00:46:16 +02:00
|
|
|
}
|
2022-02-03 16:56:13 -08:00
|
|
|
|
2023-05-26 20:41:32 +02:00
|
|
|
export function LobbyView(props: Props) {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
useLocationNavigation();
|
2022-02-04 12:38:40 -08:00
|
|
|
|
2023-05-26 20:41:32 +02:00
|
|
|
const joinCallButtonRef = React.useRef<HTMLButtonElement>();
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (joinCallButtonRef.current) {
|
2022-02-04 12:38:40 -08:00
|
|
|
joinCallButtonRef.current.focus();
|
|
|
|
}
|
2023-05-26 20:41:32 +02:00
|
|
|
}, [joinCallButtonRef]);
|
2022-02-04 12:38:40 -08:00
|
|
|
|
2022-01-05 13:09:12 -08:00
|
|
|
return (
|
|
|
|
<div className={styles.room}>
|
2023-05-26 20:41:32 +02:00
|
|
|
{!props.hideHeader && (
|
2022-09-09 02:04:53 -04:00
|
|
|
<Header>
|
|
|
|
<LeftNav>
|
2023-05-26 20:41:32 +02:00
|
|
|
<RoomHeaderInfo
|
|
|
|
roomName={props.matrixInfo.roomName}
|
|
|
|
avatarUrl={props.matrixInfo.avatarUrl}
|
|
|
|
/>
|
2022-09-09 02:04:53 -04:00
|
|
|
</LeftNav>
|
|
|
|
<RightNav>
|
|
|
|
<UserMenuContainer />
|
|
|
|
</RightNav>
|
|
|
|
</Header>
|
|
|
|
)}
|
2022-01-05 13:09:12 -08:00
|
|
|
<div className={styles.joinRoom}>
|
|
|
|
<div className={styles.joinRoomContent}>
|
2023-05-26 20:41:32 +02:00
|
|
|
<VideoPreview
|
|
|
|
matrixInfo={props.matrixInfo}
|
|
|
|
mediaDevices={props.mediaDevices}
|
|
|
|
localMediaInfo={props.localMedia}
|
|
|
|
/>
|
2022-10-24 10:17:12 -04:00
|
|
|
<Trans>
|
|
|
|
<Button
|
|
|
|
ref={joinCallButtonRef}
|
|
|
|
className={styles.copyButton}
|
|
|
|
size="lg"
|
2023-05-26 20:41:32 +02:00
|
|
|
onPress={props.onEnter}
|
2023-04-19 13:47:05 +01:00
|
|
|
data-testid="lobby_joinCall"
|
2022-10-24 10:17:12 -04:00
|
|
|
>
|
|
|
|
Join call now
|
|
|
|
</Button>
|
|
|
|
<Body>Or</Body>
|
|
|
|
<CopyButton
|
|
|
|
variant="secondaryCopy"
|
2023-05-26 20:41:32 +02:00
|
|
|
value={getRoomUrl(props.matrixInfo.roomName)}
|
2022-10-24 10:17:12 -04:00
|
|
|
className={styles.copyButton}
|
|
|
|
copiedMessage={t("Call link copied")}
|
2023-05-11 14:29:01 +01:00
|
|
|
data-testid="lobby_inviteLink"
|
2022-10-24 10:17:12 -04:00
|
|
|
>
|
|
|
|
Copy call link and join later
|
|
|
|
</CopyButton>
|
|
|
|
</Trans>
|
2022-01-05 13:09:12 -08:00
|
|
|
</div>
|
2023-05-26 20:41:32 +02:00
|
|
|
{!props.isEmbedded && (
|
2022-07-06 18:27:30 +01:00
|
|
|
<Body className={styles.joinRoomFooter}>
|
|
|
|
<Link color="primary" to="/">
|
2022-10-10 09:19:10 -04:00
|
|
|
{t("Take me Home")}
|
2022-07-06 18:27:30 +01:00
|
|
|
</Link>
|
|
|
|
</Body>
|
|
|
|
)}
|
2022-01-05 13:09:12 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|