Join room via sidebar
This commit is contained in:
parent
247b99d571
commit
30bfc6e763
|
@ -1,28 +1,42 @@
|
||||||
|
import { useState } from "react";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
import Meeting from "./components/meeting/Meeting";
|
import Meeting from "./components/meeting/Meeting";
|
||||||
import Sidebar from "./components/sidebar/Sidebar";
|
import Sidebar from "./components/sidebar/Sidebar";
|
||||||
import useBackendData from "./hooks/useBackendData";
|
import useBackendData from "./hooks/useBackendData";
|
||||||
import useConferenceData from "./hooks/useConferenceData";
|
import useConferenceData from "./hooks/useConferenceData";
|
||||||
import useLocalUser from "./hooks/useLocalUser";
|
import useLocalUser from "./hooks/useLocalUser";
|
||||||
|
import { useRoomName } from "./hooks/useRoomName";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const { userInfo, setUserInfo } = useLocalUser();
|
const { userInfo, setUserInfo } = useLocalUser();
|
||||||
|
const { roomName, updateRoomName, updateAndSubmitRoomName, submitRoomName } = useRoomName();
|
||||||
const { roomData, sendMessage } = useBackendData(userInfo);
|
const { roomData, sendMessage } = useBackendData(userInfo);
|
||||||
const { conferenceData, setConferenceData } = useConferenceData(
|
const { conferenceData, setConferenceData } = useConferenceData(
|
||||||
sendMessage,
|
sendMessage,
|
||||||
setUserInfo
|
setUserInfo
|
||||||
);
|
);
|
||||||
|
const [meetingStarted, setMeetingStarted] = useState(false);
|
||||||
|
|
||||||
console.log(roomData);
|
console.log(roomData);
|
||||||
|
|
||||||
if (roomData && userInfo) {
|
if (roomData && userInfo) {
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<Sidebar usersData={roomData} />
|
<Sidebar usersData={roomData}
|
||||||
|
updateAndSubmitRoomName={(roomName: string) => {
|
||||||
|
updateAndSubmitRoomName(roomName)
|
||||||
|
setMeetingStarted(true)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Meeting
|
<Meeting
|
||||||
conferenceData={conferenceData}
|
conferenceData={conferenceData}
|
||||||
setConferenceData={setConferenceData}
|
setConferenceData={setConferenceData}
|
||||||
userInfo={userInfo}
|
userInfo={userInfo}
|
||||||
|
roomName={roomName}
|
||||||
|
updateRoomName={updateRoomName}
|
||||||
|
submitRoomName={submitRoomName}
|
||||||
|
meetingStarted={meetingStarted}
|
||||||
|
setMeetingStarted={setMeetingStarted}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
const ISPROD = window.location.protocol == "https:";
|
const ISPROD = window.location.protocol == "https:";
|
||||||
const JITSI_DOMAIN = ISPROD
|
const JITSI_DOMAIN = "thisisnotajitsi.filefighter.de";
|
||||||
? "thisisnotajitsi.filefighter.de"
|
|
||||||
: "localhost:8443";
|
|
||||||
const WEBSOCKET_URL =
|
const WEBSOCKET_URL =
|
||||||
"ws" +
|
"ws" +
|
||||||
(ISPROD ? "s" : "") +
|
(ISPROD ? "s" : "") +
|
||||||
|
|
|
@ -9,11 +9,12 @@ interface Props {
|
||||||
conferenceData: ConferenceData | undefined;
|
conferenceData: ConferenceData | undefined;
|
||||||
setConferenceData: (newData: ConferenceData) => void;
|
setConferenceData: (newData: ConferenceData) => void;
|
||||||
userInfo: UserInfo;
|
userInfo: UserInfo;
|
||||||
|
//@ts-ignore
|
||||||
|
roomName, updateRoomName, submitRoomName
|
||||||
|
meetingStarted: Boolean, setMeetingStarted: Function
|
||||||
}
|
}
|
||||||
|
|
||||||
function Meeting({ conferenceData, setConferenceData, userInfo }: Props) {
|
function Meeting({ conferenceData, setConferenceData, userInfo, roomName, updateRoomName, submitRoomName, meetingStarted, setMeetingStarted }: Props) {
|
||||||
const { roomName, updateRoomName, submitRoomName } = useRoomName();
|
|
||||||
const [meetingStarted, setMeetingStarted] = useState(false);
|
|
||||||
|
|
||||||
const startMeeting = useCallback(() => {
|
const startMeeting = useCallback(() => {
|
||||||
submitRoomName();
|
submitRoomName();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { UsersData } from "../../background/types/roomData";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
usersData: UsersData;
|
usersData: UsersData;
|
||||||
|
updateAndSubmitRoomName: Function
|
||||||
}
|
}
|
||||||
|
|
||||||
function Sidebar(props: Props) {
|
function Sidebar(props: Props) {
|
||||||
|
@ -14,17 +15,17 @@ function Sidebar(props: Props) {
|
||||||
return (
|
return (
|
||||||
<div className={`sidebar sidebar-${sidebarVisibility}`}>
|
<div className={`sidebar sidebar-${sidebarVisibility}`}>
|
||||||
<SidebarHeader sidebarVisibility={sidebarVisibility} />
|
<SidebarHeader sidebarVisibility={sidebarVisibility} />
|
||||||
<div>
|
|
||||||
<h3> No room</h3>
|
|
||||||
{props.usersData.usersWithOutRoom.map((username) => (
|
|
||||||
<div>{username}</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
{props.usersData.roomsData.map((roomData) => {
|
{props.usersData.roomsData.map((roomData) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h3> {roomData.roomName} </h3>
|
<h3>
|
||||||
|
<a href="#" onClick={() => {
|
||||||
|
props.updateAndSubmitRoomName(roomData.roomName)
|
||||||
|
}}>
|
||||||
|
{roomData.roomName}
|
||||||
|
</a>
|
||||||
|
</h3>
|
||||||
{roomData.participants.map((participant) => (
|
{roomData.participants.map((participant) => (
|
||||||
<div> {participant.displayName} </div>
|
<div> {participant.displayName} </div>
|
||||||
))}
|
))}
|
||||||
|
@ -32,6 +33,12 @@ function Sidebar(props: Props) {
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3> No room</h3>
|
||||||
|
{props.usersData.usersWithOutRoom.map((username) => (
|
||||||
|
<div>{username}</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
<div className="sidebar-footer">
|
<div className="sidebar-footer">
|
||||||
<button onClick={toggleSidebarVisibility}>{sidebarToggleText}</button>
|
<button onClick={toggleSidebarVisibility}>{sidebarToggleText}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,12 +11,22 @@ function useRoomName() {
|
||||||
[setRoomName]
|
[setRoomName]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const updateAndSubmitRoomName = useCallback(
|
||||||
|
(newName: string) => {
|
||||||
|
setRoomName(newName);
|
||||||
|
setRoomNameInUrl(newName);
|
||||||
|
setRoomNameInTitle(newName);
|
||||||
|
console.log("[Rooms] update and submit room name", newName);
|
||||||
|
},
|
||||||
|
[setRoomName]
|
||||||
|
)
|
||||||
|
|
||||||
const submitRoomName = useCallback(() => {
|
const submitRoomName = useCallback(() => {
|
||||||
setRoomNameInUrl(roomName);
|
setRoomNameInUrl(roomName);
|
||||||
setRoomNameInTitle(roomName);
|
setRoomNameInTitle(roomName);
|
||||||
}, [roomName]);
|
}, [roomName]);
|
||||||
|
|
||||||
return { roomName, updateRoomName, submitRoomName };
|
return { roomName, updateRoomName, updateAndSubmitRoomName, submitRoomName };
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRoomNameFromUrl(): string {
|
function getRoomNameFromUrl(): string {
|
||||||
|
|
Loading…
Reference in a new issue