-
-
- {publicRooms.length > 0 && (
- <>
-
Public Calls
-
- {publicRooms.map((room) => (
-
- ))}
-
- >
- )}
-
Recent Calls
-
- {rooms.map(({ room, participants }) => (
-
- ))}
+ {!hideCallList && (
+
+
+
+ {publicRooms.length > 0 && (
+
+ )}
+ {recentRooms.length > 0 && (
+
+ )}
-
+ )}
);
}
diff --git a/src/Home.module.css b/src/Home.module.css
index 182cf73..b9f79f4 100644
--- a/src/Home.module.css
+++ b/src/Home.module.css
@@ -15,6 +15,11 @@
background-color: var(--bgColor2);
}
+.fullWidth {
+ background-color: var(--bgColor1);
+ overflow-y: auto;
+}
+
.centered {
display: flex;
flex-direction: column;
@@ -65,6 +70,10 @@
top: -12px;
}
+.fullWidth .content hr:after {
+ background-color: var(--bgColor1);
+}
+
.left .content form {
display: flex;
flex-direction: column;
@@ -99,11 +108,3 @@
.right .content h3:first-child {
margin-top: 0;
}
-
-.roomList {
- display: flex;
- flex-wrap: wrap;
- justify-content: flex-start;
- gap: 24px;
- flex: 1;
-}
diff --git a/src/LoginPage.jsx b/src/LoginPage.jsx
index cf3bc7b..6c92c18 100644
--- a/src/LoginPage.jsx
+++ b/src/LoginPage.jsx
@@ -20,8 +20,10 @@ import { Header, HeaderLogo, LeftNav } from "./Header";
import { FieldRow, InputField, ErrorMessage } from "./Input";
import { Center, Content, Info, Modal } from "./Layout";
import { Button } from "./button";
+import { useClient } from "./ConferenceCallManagerHooks";
-export function LoginPage({ onLogin }) {
+export function LoginPage() {
+ const { login } = useClient();
const [homeserver, setHomeServer] = useState(
`${window.location.protocol}//${window.location.host}`
);
@@ -32,17 +34,19 @@ export function LoginPage({ onLogin }) {
const [loading, setLoading] = useState(false);
const [error, setError] = useState();
+ // TODO: Handle hitting login page with authenticated client
+
const onSubmitLoginForm = useCallback(
(e) => {
e.preventDefault();
setLoading(true);
- onLogin(homeserver, usernameRef.current.value, passwordRef.current.value)
+ login(homeserver, usernameRef.current.value, passwordRef.current.value)
.then(() => {
if (location.state && location.state.from) {
- history.replace(location.state.from);
+ history.push(location.state.from);
} else {
- history.replace("/");
+ history.push("/");
}
})
.catch((error) => {
@@ -50,7 +54,7 @@ export function LoginPage({ onLogin }) {
setLoading(false);
});
},
- [onLogin, location, history, homeserver]
+ [login, location, history, homeserver]
);
return (
diff --git a/src/RegisterPage.jsx b/src/RegisterPage.jsx
index 2b21afe..434df33 100644
--- a/src/RegisterPage.jsx
+++ b/src/RegisterPage.jsx
@@ -20,8 +20,11 @@ import { Header, LeftNav, HeaderLogo } from "./Header";
import { FieldRow, InputField, ErrorMessage } from "./Input";
import { Center, Content, Info, Modal } from "./Layout";
import { Button } from "./button";
+import { useClient } from "./ConferenceCallManagerHooks";
-export function RegisterPage({ onRegister }) {
+export function RegisterPage() {
+ // TODO: Handle hitting login page with authenticated client
+ const { register } = useClient();
const registerUsernameRef = useRef();
const registerPasswordRef = useRef();
const history = useHistory();
@@ -33,15 +36,15 @@ export function RegisterPage({ onRegister }) {
(e) => {
e.preventDefault();
setLoading(true);
- onRegister(
+ register(
registerUsernameRef.current.value,
registerPasswordRef.current.value
)
.then(() => {
if (location.state && location.state.from) {
- history.replace(location.state.from);
+ history.push(location.state.from);
} else {
- history.replace("/");
+ history.push("/");
}
})
.catch((error) => {
@@ -49,7 +52,7 @@ export function RegisterPage({ onRegister }) {
setLoading(false);
});
},
- [onRegister, location, history]
+ [register, location, history]
);
return (
diff --git a/src/Room.jsx b/src/Room.jsx
index ea89941..29f710f 100644
--- a/src/Room.jsx
+++ b/src/Room.jsx
@@ -42,7 +42,7 @@ import "matrix-react-sdk/res/css/views/voip/GroupCallView/_VideoGrid.scss";
import { useGroupCall } from "matrix-react-sdk/src/hooks/useGroupCall";
import { useCallFeed } from "matrix-react-sdk/src/hooks/useCallFeed";
import { useMediaStream } from "matrix-react-sdk/src/hooks/useMediaStream";
-import { fetchGroupCall } from "./ConferenceCallManagerHooks";
+import { useClient, useLoadGroupCall } from "./ConferenceCallManagerHooks";
import { ErrorModal } from "./ErrorModal";
import { GroupCallInspector } from "./GroupCallInspector";
import * as Sentry from "@sentry/react";
@@ -56,24 +56,39 @@ const canScreenshare = "getDisplayMedia" in navigator.mediaDevices;
// For now we can disable screensharing in Safari.
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
-function useLoadGroupCall(client, roomId, viaServers) {
- const [state, setState] = useState({
- loading: true,
- error: undefined,
- groupCall: undefined,
- });
+export function Room() {
+ const [registeringGuest, setRegisteringGuest] = useState(false);
+ const [registrationError, setRegistrationError] = useState();
+ const { loading, isAuthenticated, error, client, registerGuest } =
+ useClient();
useEffect(() => {
- setState({ loading: true });
- fetchGroupCall(client, roomId, viaServers, 30000)
- .then((groupCall) => setState({ loading: false, groupCall }))
- .catch((error) => setState({ loading: false, error }));
- }, [roomId]);
+ if (!loading && !isAuthenticated) {
+ setRegisteringGuest(true);
- return state;
+ registerGuest()
+ .then(() => {
+ setRegisteringGuest(false);
+ })
+ .catch((error) => {
+ setRegistrationError(error);
+ setRegisteringGuest(false);
+ });
+ }
+ }, [loading, isAuthenticated]);
+
+ if (loading || registeringGuest) {
+ return
Loading...
;
+ }
+
+ if (registrationError || error) {
+ return
;
+ }
+
+ return
;
}
-export function Room({ client, onLogout }) {
+export function GroupCall({ client }) {
const { roomId: maybeRoomId } = useParams();
const { hash, search } = useLocation();
const [simpleGrid, viaServers] = useMemo(() => {
@@ -115,7 +130,6 @@ export function Room({ client, onLogout }) {
return (
-
+
@@ -347,7 +354,6 @@ function RoomSetupView({
}
function InRoomView({
- onLogout,
client,
groupCall,
roomName,
@@ -424,11 +430,7 @@ function InRoomView({
-
+
{items.length === 0 ? (
diff --git a/src/UserMenu.jsx b/src/UserMenu.jsx
index ddf7885..8fd6f03 100644
--- a/src/UserMenu.jsx
+++ b/src/UserMenu.jsx
@@ -7,45 +7,67 @@ import { ReactComponent as LogoutIcon } from "./icons/Logout.svg";
import styles from "./UserMenu.module.css";
import { Item } from "@react-stately/collections";
import { Menu } from "./Menu";
+import { useHistory, useLocation } from "react-router-dom";
+import { useClient } from "./ConferenceCallManagerHooks";
-export function UserMenu({ userName, signedIn, onLogin, onLogout }) {
- const onAction = useCallback((value) => {
- switch (value) {
- case "user":
- break;
- case "logout":
- onLogout();
- break;
- case "login":
- onLogin();
- break;
- }
- });
+export function UserMenu() {
+ const location = useLocation();
+ const history = useHistory();
+ const { isAuthenticated, isGuest, logout, userName } = useClient();
+
+ const onAction = useCallback(
+ (value) => {
+ switch (value) {
+ case "user":
+ break;
+ case "logout":
+ logout();
+ break;
+ case "login":
+ history.push("/login", { state: { from: location } });
+ break;
+ case "register":
+ history.push("/register", { state: { from: location } });
+ break;
+ }
+ },
+ [history, location, logout]
+ );
const items = useMemo(() => {
- if (signedIn) {
- return [
- {
- key: "user",
- icon: UserIcon,
- label: userName,
- },
- {
- key: "logout",
- label: "Sign Out",
- icon: LogoutIcon,
- },
- ];
- } else {
- return [
+ const arr = [];
+
+ if (isAuthenticated) {
+ arr.push({
+ key: "user",
+ icon: UserIcon,
+ label: userName,
+ });
+ }
+
+ if (!isAuthenticated || isGuest) {
+ arr.push(
{
key: "login",
label: "Sign In",
icon: LoginIcon,
},
- ];
+ {
+ key: "register",
+ label: "Register",
+ icon: LoginIcon,
+ }
+ );
+ } else {
+ arr.push({
+ key: "logout",
+ label: "Sign Out",
+ icon: LogoutIcon,
+ });
}
- }, [signedIn, userName]);
+
+ return arr;
+ }, [isAuthenticated, isGuest, userName]);
return (