diff --git a/packages/common/models/conversation.ts b/packages/common/models/conversation.ts index 3106294..253caad 100644 --- a/packages/common/models/conversation.ts +++ b/packages/common/models/conversation.ts @@ -126,6 +126,10 @@ export class Link { return LinkType.pdf; } else if (url.includes(LinkType.codePile)) { return LinkType.codePile; + } else if (url.includes("meet.google.com")) { + return LinkType.googleMeet; + } else if (url.includes(".zoom.")) { + return LinkType.zoom; } else { return LinkType.default; } @@ -143,4 +147,5 @@ export enum LinkType { codePile = "codepile", pastePics = "paste.pics", googleMeet = "googleMeet", + zoom = "zoom", } diff --git a/packages/web/components/Drawer/CreateItemModal.tsx b/packages/web/components/Drawer/CreateItemModal.tsx new file mode 100644 index 0000000..e8fbee2 --- /dev/null +++ b/packages/web/components/Drawer/CreateItemModal.tsx @@ -0,0 +1,61 @@ +import { Link } from "@nirvana/common/models/conversation"; +import Modal from "antd/lib/modal/Modal"; +import { useState, useEffect } from "react"; +import toast from "react-hot-toast"; +import LinkIcon from "./LinkIcon"; + +export default function CreateItemModal(props: { + pastedLink: string; + show: boolean; +}) { + const [linkVal, setLinkVal] = useState(""); + + useEffect(() => { + if (props.pastedLink) { + setLinkVal(props.pastedLink); + } + }, [props.pastedLink]); + + const handleCreate = () => { + console.log("added drawer item"); + toast.success("added drawer item to conversation"); + }; + + const handleCancel = () => { + toast.success("closing"); + }; + + return ( + + + + Link + + Please make sure this is valid for others to access. + + {/* icon and link input */} + + + + setLinkVal(e.target.value)} + /> + + + + + ); +} diff --git a/packages/web/components/Drawer/LinkIcon.tsx b/packages/web/components/Drawer/LinkIcon.tsx index a88c91d..046f73a 100644 --- a/packages/web/components/Drawer/LinkIcon.tsx +++ b/packages/web/components/Drawer/LinkIcon.tsx @@ -10,7 +10,7 @@ import { } from "react-icons/fa"; import Link, { LinkType } from "@nirvana/common/models/conversation"; -import { SiGooglemeet } from "react-icons/si"; +import { SiGooglemeet, SiZoom } from "react-icons/si"; export default function LinkIcon(props: { className?: string; @@ -61,6 +61,8 @@ export default function LinkIcon(props: { return ( ); + case LinkType.zoom: + return ; default: return ( diff --git a/packages/web/components/MainTabsOrPages/ViewConvo.tsx b/packages/web/components/MainTabsOrPages/ViewConvo.tsx index 603bc41..2e71f8f 100644 --- a/packages/web/components/MainTabsOrPages/ViewConvo.tsx +++ b/packages/web/components/MainTabsOrPages/ViewConvo.tsx @@ -55,7 +55,9 @@ import { firestoreDb as db } from "../../services/firebaseService"; import Collections from "@nirvana/common/services/collections"; import TimelineAudioClip from "../Conversations/TimelineAudioClip"; import Modal from "antd/lib/modal/Modal"; -import { configure } from "react-hotkeys"; +import { configure, GlobalHotKeys, KeyMap } from "react-hotkeys"; +import CreateItemModal from "../Drawer/CreateItemModal"; +import isValidHttpUrl from "../../helpers/urlHelper"; const testDrawerItems: { linkType: LinkType; @@ -240,18 +242,44 @@ export default function ViewConvo(props: { conversationId: string }) { const isRecording = useRecoilValue(isRecordingAtom); const audioQueueCurrentItem = useRecoilValue(audioQueueCurrentClipSelector); + const [showItemModal, setShowItemModal] = useState(false); + const [pastedLink, setPastedLink] = useState(""); + + const handleOpenDrawerItemModal = () => { + navigator.clipboard + .readText() + .then((text) => { + console.log("Pasted content: ", text); + + // check that the link is valid + if (!isValidHttpUrl(text)) { + toast.error("Not a valid link"); + return; + } + + // set it as we should show modal regardless now + setPastedLink(text); + + setShowItemModal(true); + }) + .catch((err) => { + console.error("Failed to read clipboard contents: ", err); + toast.error("Please enable permissions for clipboard"); + }); + }; + + const keyMap: KeyMap = { + PASTE_LINK: "ctrl+v", + }; + + const handlers = { + PASTE_LINK: handleOpenDrawerItemModal, + }; + return ( <> - {/* -

Some contents...

-

Some contents...

-

Some contents...

-
*/} + +
{/* convo name and action buttons on top */}