diff --git a/components/Modals/CreateRoom.tsx b/components/Modals/CreateRoom.tsx index 7b47246..d7ed932 100644 --- a/components/Modals/CreateRoom.tsx +++ b/components/Modals/CreateRoom.tsx @@ -1,18 +1,32 @@ import { Modal } from "antd"; -import { useKeyboardContext } from "../../contexts/keyboardContext"; +import { useEffect } from "react"; +import { + ShowModalType, + useKeyboardContext, +} from "../../contexts/keyboardContext"; -export default function CreateRoom() { - const { createRoom } = useKeyboardContext(); +const thisModalType = ShowModalType.createRoom; - console.log(createRoom); +export default function CreateRoomModal() { + const { pastedLink, handleModalType, showModalType } = useKeyboardContext(); + + useEffect(() => { + // check if link is valid google meet link + }, []); + + const handleCloseModal = () => { + handleModalType(ShowModalType.na); + }; + + const handleSubmit = () => {}; return ( this.setModal2Visible(false)} - // onCancel={() => this.setModal2Visible(false)} + visible={showModalType == thisModalType ? true : false} + onOk={handleSubmit} + onCancel={handleCloseModal} >

some contents...

some contents...

diff --git a/contexts/keyboardContext.tsx b/contexts/keyboardContext.tsx index e7f45a3..68673e2 100644 --- a/contexts/keyboardContext.tsx +++ b/contexts/keyboardContext.tsx @@ -12,7 +12,6 @@ import { Message } from "../models/message"; import { useAuth } from "./authContext"; import { SendService } from "../services/sendService"; import { useTeamDashboardContext } from "./teamDashboardContext"; -import CreateRoom from "../helpers/CreateRoom"; interface KeyboardContextInterface { selectedTeammate: string; // can only have one selected @@ -45,7 +44,15 @@ interface KeyboardContextInterface { ctrlDown: boolean; - createRoom: CreateRoom; + showModalType: ShowModalType; + handleModalType: Function; + pastedLink: string; +} + +export enum ShowModalType { + createLink = "link", + createRoom = "room", + na = "none", } const KeyboardContext = React.createContext( @@ -85,7 +92,14 @@ export default function KeyboardContextProvider({ children }) { const [isMuted, setIsMuted] = useState(false); const [isSilenceMode, setIseSilenceMode] = useState(false); - const [createRoom, setCreateRoom] = useState(new CreateRoom()); + const [pastedLink, setPastedLink] = useState(null); + const [showModalType, setShowModalType] = useState( + ShowModalType.na + ); + + const handleModalType = (modalType: ShowModalType) => { + setShowModalType(modalType); + }; const [recorder, setRecorder] = useState( new MicRecorder({ bitRate: 128 }) @@ -137,7 +151,10 @@ export default function KeyboardContextProvider({ children }) { outputDevices, ctrlDown, - createRoom, + + pastedLink, + handleModalType, + showModalType, }; function muteOrUnmute() { @@ -222,11 +239,6 @@ export default function KeyboardContextProvider({ children }) { ); }, [audioInputDeviceId]); // change it everytime we change the input device - // auto play - useEffect(() => { - // todo play audio to selected output device - }, []); - // SECTION: recording async function startRecording() { recorder @@ -358,7 +370,7 @@ export default function KeyboardContextProvider({ children }) { toast.error("select a team member first to play"); } else { // alright now you are good to play last message chunk in conversation with selected user - // todo create last chunk, and create a playlist + // todo create last chunk by iterating until next person, and create a playlist if ( selectedTeammate in messagesByTeamMate && @@ -380,6 +392,12 @@ export default function KeyboardContextProvider({ children }) { toast("navigating to create google meet"); window.open(new URL("https://meet.google.com/"), "_blank"); + } else if (event.keyCode == KeyCode.V && ctrlDown) { + toast("pasting link"); + + setSelectedTeamMember(null); + + setShowModalType(ShowModalType.createRoom); } else { toast("Invalid keyboard shortcut."); } diff --git a/helpers/CreateRoom.tsx b/helpers/CreateRoom.tsx deleted file mode 100644 index bde8364..0000000 --- a/helpers/CreateRoom.tsx +++ /dev/null @@ -1,11 +0,0 @@ -export default class CreateRoom { - showModal: boolean; - - meetLink?: string; - - constructor() { - this.showModal = false; - - this.meetLink = ""; - } -}