From 6ce8a9f0e05ec18aeb8f1cdd010275cc36c34916 Mon Sep 17 00:00:00 2001 From: Arjun Patel Date: Sun, 16 Jan 2022 15:26:43 -0800 Subject: [PATCH] adding control stuff for google meet --- components/Dashboard/Rooms.tsx | 34 ++++++++++++++++++++++++++++++++-- contexts/audioContext.tsx | 23 +++++++++++++++++++---- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/components/Dashboard/Rooms.tsx b/components/Dashboard/Rooms.tsx index 4632e8b..fab4cf7 100644 --- a/components/Dashboard/Rooms.tsx +++ b/components/Dashboard/Rooms.tsx @@ -1,11 +1,37 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { FaAngleDown, FaBell, FaClock, FaPlus, FaLink } from "react-icons/fa"; import { IoTimer } from "react-icons/io5"; import { BsThreeDots } from "react-icons/bs"; import Image from "next/image"; +enum RoomTypeFilter { + all = "all", + live = "live", + scheduled = "scheduled", + recurring = "recurring", + expired = "expired", +} + +enum RoomTimeFilter { + today = "today", + week = "week", + month = "month", +} + export default function DashboardRoom() { + // get rooms data realtime + useEffect(() => { + /** + * QUERY: + * all rooms in the past week + * + */ + }); + + // on CTRL + Q, new tab to google meet + // on CTRL + V, show modal to create meeting with the link + return (
{/* header */} @@ -16,7 +42,7 @@ export default function DashboardRoom() { className="right-1 rounded-lg py-1 px-2 ml-1 shadow-md text-center text-white text-sm font-bold" > - CTRL + R + CTRL + Q @@ -37,6 +63,10 @@ export default function DashboardRoom() { Recurring + + + Expired + diff --git a/contexts/audioContext.tsx b/contexts/audioContext.tsx index 748422f..1bd8fe5 100644 --- a/contexts/audioContext.tsx +++ b/contexts/audioContext.tsx @@ -41,6 +41,8 @@ interface AudioContextInterface { inputDevices: MediaDeviceInfo[]; outputDevices: MediaDeviceInfo[]; + + ctrlDown: boolean; } const AudioContext = React.createContext(null); @@ -66,6 +68,8 @@ export default function AudioContextProvider({ children }) { const [isRecording, setIsRecording] = useState(false); const [hasRecPermit, setHasRecPermit] = useState(false); + const [ctrlDown, setCtrlDown] = useState(false); + const [teamShortcutMappings, setTeamShortcutMappings] = useState<{}>({}); const [audioInputDeviceId, setAudioInputDevice] = useState(null); // device id const [audioOutputDeviceId, setAudioOutputDevice] = useState(null); // device id @@ -124,6 +128,8 @@ export default function AudioContextProvider({ children }) { inputDevices, outputDevices, + + ctrlDown, }; function muteOrUnmute() { @@ -259,11 +265,10 @@ export default function AudioContextProvider({ children }) { // if there are still items in the player queue, then change the src and play the subsequent messages } - // todo usecallback hook - const handleKeyUp = useCallback( (event) => { console.log("on key up"); + console.log(event.keyCode); // if was recording and released R, then stop recording and send message if (event.keyCode == KeyCode.R && selectedTeammate && isRecording) { @@ -300,6 +305,8 @@ export default function AudioContextProvider({ children }) { console.log("sending message to " + selectedTeammate); setSelectedTeamMember(null); + } else if (event.keyCode == KeyCode.Ctrl) { + setCtrlDown(false); } }, [isRecording, selectedTeammate] @@ -312,10 +319,9 @@ export default function AudioContextProvider({ children }) { } console.log(event.keyCode); - console.log(selectedTeammate); // recording - if (event.keyCode == KeyCode.R) { + if (event.keyCode == KeyCode.R && !ctrlDown) { if (!audioInputDeviceId) { toast.error("No microphone selected"); } else if (!hasRecPermit) { @@ -337,6 +343,7 @@ export default function AudioContextProvider({ children }) { } else if (event.keyCode == KeyCode.Escape) { setSelectedTeamMember(null); } else if (event.keyCode == KeyCode.Space) { + // listen to last message in convo if (isSilenceMode) { toast.error("you are in silence mode, please disable it first"); } else if (!selectedTeammate) { @@ -358,6 +365,13 @@ export default function AudioContextProvider({ children }) { toast("nothing to play"); } } + } else if (event.keyCode == KeyCode.Ctrl) { + setCtrlDown(true); + toast("control down"); + } else if (event.keyCode == KeyCode.Q && ctrlDown) { + toast("navigating to create google meet"); + + window.open(new URL("https://meet.google.com/"), "_blank"); } else { toast("Invalid keyboard shortcut."); } @@ -372,6 +386,7 @@ export default function AudioContextProvider({ children }) { hasRecPermit, isMuted, teamShortcutMappings, + ctrlDown, ] );