Add login button to lobby screen

This commit is contained in:
Robert Long 2021-12-13 16:16:25 -08:00
commit c3f4f32107
4 changed files with 38 additions and 5 deletions

View file

@ -24,6 +24,7 @@ import {
MicButton, MicButton,
VideoButton, VideoButton,
ScreenshareButton, ScreenshareButton,
LinkButton,
} from "./button"; } from "./button";
import { import {
Header, Header,
@ -59,9 +60,11 @@ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
export function Room() { export function Room() {
const [registeringGuest, setRegisteringGuest] = useState(false); const [registeringGuest, setRegisteringGuest] = useState(false);
const [registrationError, setRegistrationError] = useState(); const [registrationError, setRegistrationError] = useState();
const { loading, isAuthenticated, error, client, registerGuest } = const { loading, isAuthenticated, error, client, registerGuest, isGuest } =
useClient(); useClient();
console.log({ isGuest });
useEffect(() => { useEffect(() => {
if (!loading && !isAuthenticated) { if (!loading && !isAuthenticated) {
setRegisteringGuest(true); setRegisteringGuest(true);
@ -85,10 +88,10 @@ export function Room() {
return <ErrorView error={registrationError || error} />; return <ErrorView error={registrationError || error} />;
} }
return <GroupCall client={client} />; return <GroupCall client={client} isGuest={isGuest} />;
} }
export function GroupCall({ client }) { export function GroupCall({ client, isGuest }) {
const { roomId: maybeRoomId } = useParams(); const { roomId: maybeRoomId } = useParams();
const { hash, search } = useLocation(); const { hash, search } = useLocation();
const [simpleGrid, viaServers] = useMemo(() => { const [simpleGrid, viaServers] = useMemo(() => {
@ -116,6 +119,7 @@ export function GroupCall({ client }) {
return ( return (
<GroupCallView <GroupCallView
isGuest={isGuest}
client={client} client={client}
roomId={roomId} roomId={roomId}
groupCall={groupCall} groupCall={groupCall}
@ -124,7 +128,13 @@ export function GroupCall({ client }) {
); );
} }
export function GroupCallView({ client, roomId, groupCall, simpleGrid }) { export function GroupCallView({
client,
isGuest,
roomId,
groupCall,
simpleGrid,
}) {
const [showInspector, setShowInspector] = useState(false); const [showInspector, setShowInspector] = useState(false);
const { const {
state, state,
@ -200,6 +210,7 @@ export function GroupCallView({ client, roomId, groupCall, simpleGrid }) {
} else { } else {
return ( return (
<RoomSetupView <RoomSetupView
isGuest={isGuest}
client={client} client={client}
hasLocalParticipant={hasLocalParticipant} hasLocalParticipant={hasLocalParticipant}
roomName={groupCall.room.name} roomName={groupCall.room.name}
@ -237,6 +248,7 @@ export function EnteringRoomView() {
function RoomSetupView({ function RoomSetupView({
client, client,
isGuest,
roomName, roomName,
state, state,
onInitLocalCallFeed, onInitLocalCallFeed,
@ -252,6 +264,7 @@ function RoomSetupView({
}) { }) {
const { stream } = useCallFeed(localCallFeed); const { stream } = useCallFeed(localCallFeed);
const videoRef = useMediaStream(stream, true); const videoRef = useMediaStream(stream, true);
const location = useLocation();
useEffect(() => { useEffect(() => {
onInitLocalCallFeed(); onInitLocalCallFeed();
@ -264,7 +277,13 @@ function RoomSetupView({
<RoomHeaderInfo roomName={roomName} /> <RoomHeaderInfo roomName={roomName} />
</LeftNav> </LeftNav>
<RightNav> <RightNav>
<UserMenu /> {isGuest ? (
<LinkButton to={{ pathname: "/login", state: { from: location } }}>
Log in
</LinkButton>
) : (
<UserMenu />
)}
</RightNav> </RightNav>
</Header> </Header>
<div className={styles.joinRoom}> <div className={styles.joinRoom}>

View file

@ -28,6 +28,7 @@ limitations under the License.
padding: 0; padding: 0;
border: none; border: none;
cursor: pointer; cursor: pointer;
text-decoration: none;
} }
.secondary, .secondary,

12
src/button/LinkButton.jsx Normal file
View file

@ -0,0 +1,12 @@
import React from "react";
import { Link } from "react-router-dom";
import classNames from "classnames";
import styles from "./Button.module.css";
export function LinkButton({ className, children, ...rest }) {
return (
<Link className={classNames(styles.secondary, className)} {...rest}>
{children}
</Link>
);
}

View file

@ -1,2 +1,3 @@
export * from "./Button"; export * from "./Button";
export * from "./CopyButton"; export * from "./CopyButton";
export * from "./LinkButton";