Add login button to lobby screen
This commit is contained in:
parent
48d011fb69
commit
c3f4f32107
4 changed files with 38 additions and 5 deletions
29
src/Room.jsx
29
src/Room.jsx
|
|
@ -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}>
|
||||||
|
|
|
||||||
|
|
@ -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
12
src/button/LinkButton.jsx
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
export * from "./Button";
|
export * from "./Button";
|
||||||
export * from "./CopyButton";
|
export * from "./CopyButton";
|
||||||
|
export * from "./LinkButton";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue