Minor refactoring

This commit is contained in:
qvalentin 2023-01-10 19:00:20 +01:00
parent ffa4d26836
commit 6ec914e738
6 changed files with 28 additions and 14 deletions

View File

@ -1,11 +1,17 @@
import { JitsiMeeting } from "@jitsi/react-sdk"; import { JitsiMeeting } from "@jitsi/react-sdk";
import { JITSI_DOMAIN } from "../../background/constants"; import { JITSI_DOMAIN } from "../../background/constants";
import { UserInfo } from "./types";
function JitsiEntrypoint() { interface Props {
roomName: string;
userInfo: UserInfo;
}
function JitsiEntrypoint({ roomName, userInfo }: Props) {
return ( return (
<JitsiMeeting <JitsiMeeting
domain={JITSI_DOMAIN} domain={JITSI_DOMAIN}
roomName="PleaseUseAGoodRoomName" roomName={roomName}
configOverwrite={{ configOverwrite={{
startWithAudioMuted: true, startWithAudioMuted: true,
disableModeratorIndicator: true, disableModeratorIndicator: true,
@ -14,10 +20,7 @@ function JitsiEntrypoint() {
prejoinConfig: { enabled: false }, prejoinConfig: { enabled: false },
}} }}
interfaceConfigOverwrite={{}} interfaceConfigOverwrite={{}}
userInfo={{ userInfo={userInfo}
displayName: "YOUR_USERNAME",
email: "",
}}
onApiReady={(externalApi) => { onApiReady={(externalApi) => {
// here you can attach custom event listeners to the Jitsi Meet External API // here you can attach custom event listeners to the Jitsi Meet External API
// you can also store it locally to execute commands // you can also store it locally to execute commands

View File

@ -0,0 +1,7 @@
interface UserInfo {
displayName: string;
email: string
}
export { UserInfo }

View File

@ -1,19 +1,23 @@
import { useCallback, useState } from "react"; import { useCallback, useState } from "react";
import { useRoomName } from "../../hooks/useRoomName"; import { useRoomName } from "../../hooks/useRoomName";
import JitsiEntrypoint from "../jitsi/JitsiEntrypoint"; import JitsiEntrypoint from "../jitsi/JitsiEntrypoint";
import { UserInfo } from "../jitsi/types";
import MeetingNameInput from "./MeetingNameInput"; import MeetingNameInput from "./MeetingNameInput";
function Meeting() { function Meeting() {
const { roomName, updateRoomName, submitRoomName } = useRoomName(); const { roomName, updateRoomName, submitRoomName } = useRoomName();
const [meetingStarted, setMeetingStarted] = useState(false); const [meetingStarted, setMeetingStarted] = useState(false);
const userInfo: UserInfo = { displayName: "unknown traveller", email: "" }
const startMeeting = useCallback(() => { const startMeeting = useCallback(() => {
submitRoomName(); submitRoomName();
setMeetingStarted(true); setMeetingStarted(true);
}, [submitRoomName, setMeetingStarted]); }, [submitRoomName, setMeetingStarted]);
if (meetingStarted) { if (meetingStarted) {
return <JitsiEntrypoint />; return <JitsiEntrypoint roomName={roomName} userInfo={userInfo} />;
} }
return ( return (
@ -21,7 +25,7 @@ function Meeting() {
roomName={roomName} roomName={roomName}
setName={updateRoomName} setName={updateRoomName}
submit={startMeeting} submit={startMeeting}
currentUser="unknown traveller" currentUser={userInfo.displayName}
/> />
); );
} }

View File

@ -7,12 +7,12 @@
margin-top: auto; margin-top: auto;
} }
.sidebar.small { .sidebar-small {
min-width: 60px; min-width: 60px;
max-width: 60px; max-width: 60px;
} }
.sidebar.hidden > .sidebar-footer { .sidebar-hidden > .sidebar-footer {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
} }

View File

@ -7,7 +7,7 @@ function Sidebar() {
useSidebarVisibility(); useSidebarVisibility();
return ( return (
<div className={"sidebar " + sidebarVisibility}> <div className={`sidebar ${sidebarVisibility}`}>
<SidebarHeader sidebarVisibility={sidebarVisibility} /> <SidebarHeader sidebarVisibility={sidebarVisibility} />
<div className="sidebar-footer"> <div className="sidebar-footer">
<button onClick={toggleSidebarVisibility}>{sidebarToggleText}</button> <button onClick={toggleSidebarVisibility}>{sidebarToggleText}</button>

View File

@ -9,11 +9,11 @@ function useSidebarVisibility() {
const sidebarToggleText = getSidebarToggleText(sidebarVisibility); const sidebarToggleText = getSidebarToggleText(sidebarVisibility);
const toggleSidebarVisibility = useCallback(() => { const toggleSidebarVisibility = useCallback(() => {
if (sidebarVisibility == "full") { if (sidebarVisibility === "full") {
setSideBarVisibility("small"); setSideBarVisibility("small");
} else if (sidebarVisibility == "small") { } else if (sidebarVisibility === "small") {
setSideBarVisibility("hidden"); setSideBarVisibility("hidden");
} else if (sidebarVisibility == "hidden") { } else if (sidebarVisibility === "hidden") {
setSideBarVisibility("full"); setSideBarVisibility("full");
} }
}, [setSideBarVisibility, sidebarVisibility, sidebarToggleText]); }, [setSideBarVisibility, sidebarVisibility, sidebarToggleText]);