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-07-17 16:53:58 +02:00
|
|
|
import { useRef, useEffect, useState, useCallback, ChangeEvent } from "react";
|
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-06-16 18:07:13 +02:00
|
|
|
import { MatrixInfo, VideoPreview } from "./VideoPreview";
|
2023-07-17 16:53:58 +02:00
|
|
|
import { E2EEConfig, UserChoices } from "../livekit/useLiveKit";
|
|
|
|
|
import { InputField } from "../input/Input";
|
2023-07-25 11:07:20 +02:00
|
|
|
import { useEnableE2EE } from "../settings/useSetting";
|
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;
|
|
|
|
|
|
2023-07-17 16:53:58 +02:00
|
|
|
onEnter: (userChoices: UserChoices, e2eeConfig?: E2EEConfig) => void;
|
2022-08-02 00:46:16 +02:00
|
|
|
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-07-25 11:07:20 +02:00
|
|
|
const [enableE2EE] = useEnableE2EE();
|
|
|
|
|
|
2023-06-30 16:43:28 +01:00
|
|
|
const joinCallButtonRef = useRef<HTMLButtonElement>(null);
|
2023-06-30 18:21:18 -04:00
|
|
|
useEffect(() => {
|
2023-05-26 20:41:32 +02:00
|
|
|
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
|
|
|
|
2023-06-30 18:21:18 -04:00
|
|
|
const [userChoices, setUserChoices] = useState<UserChoices | undefined>(
|
2023-06-16 18:07:13 +02:00
|
|
|
undefined
|
|
|
|
|
);
|
2023-07-17 16:53:58 +02:00
|
|
|
const [e2eeSharedKey, setE2EESharedKey] = useState<string | undefined>(
|
|
|
|
|
undefined
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const onE2EESharedKeyChanged = useCallback(
|
|
|
|
|
(event: ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
const value = event.target.value;
|
|
|
|
|
setE2EESharedKey(value === "" ? undefined : value);
|
|
|
|
|
},
|
|
|
|
|
[setE2EESharedKey]
|
|
|
|
|
);
|
2023-06-16 18:07:13 +02: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-06-29 08:03:30 +02:00
|
|
|
<RoomHeaderInfo roomName={props.matrixInfo.roomName} />
|
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}
|
2023-06-16 18:07:13 +02:00
|
|
|
onUserChoicesChanged={setUserChoices}
|
2023-05-26 20:41:32 +02:00
|
|
|
/>
|
2023-07-25 11:07:20 +02:00
|
|
|
{enableE2EE && (
|
|
|
|
|
<InputField
|
|
|
|
|
className={styles.passwordField}
|
2023-07-25 13:03:31 +02:00
|
|
|
label={t("Password (if none, E2EE is disabled)")}
|
2023-07-25 11:07:20 +02:00
|
|
|
type="text"
|
|
|
|
|
onChange={onE2EESharedKeyChanged}
|
|
|
|
|
value={e2eeSharedKey}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2022-10-24 10:17:12 -04:00
|
|
|
<Trans>
|
|
|
|
|
<Button
|
|
|
|
|
ref={joinCallButtonRef}
|
|
|
|
|
className={styles.copyButton}
|
|
|
|
|
size="lg"
|
2023-07-17 16:53:58 +02:00
|
|
|
onPress={() =>
|
|
|
|
|
props.onEnter(
|
|
|
|
|
userChoices!,
|
|
|
|
|
e2eeSharedKey ? { sharedKey: e2eeSharedKey } : undefined
|
|
|
|
|
)
|
|
|
|
|
}
|
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-07-04 18:46:27 +01:00
|
|
|
value={getRoomUrl(props.matrixInfo.roomId)}
|
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>
|
|
|
|
|
);
|
|
|
|
|
}
|