From 0cc906909117bc22f16b0cb1914fb8da4b128206 Mon Sep 17 00:00:00 2001 From: Dhravya Shah Date: Fri, 9 Aug 2024 23:16:23 -0700 Subject: [PATCH] slow wait and save --- apps/extension/content/ContentApp.tsx | 64 +- apps/extension/content/showCommandMenu.tsx | 82 + apps/extension/content/store.ts | 47 + .../content/ui/components/Command.tsx | 156 + .../ui/components/command/AiSearch.tsx | 72 + .../ui/components/command/CommandSearch.tsx | 63 + .../content/ui/components/command/Footer.tsx | 21 + .../ui/components/command/GroupLabel.tsx | 16 + .../content/ui/components/command/Item.tsx | 20 + apps/extension/package.json | 6 +- apps/extension/public/output.css | 4256 ++++++++++++++++- pnpm-lock.yaml | 24 + 12 files changed, 4800 insertions(+), 27 deletions(-) create mode 100644 apps/extension/content/showCommandMenu.tsx create mode 100644 apps/extension/content/store.ts create mode 100644 apps/extension/content/ui/components/Command.tsx create mode 100644 apps/extension/content/ui/components/command/AiSearch.tsx create mode 100644 apps/extension/content/ui/components/command/CommandSearch.tsx create mode 100644 apps/extension/content/ui/components/command/Footer.tsx create mode 100644 apps/extension/content/ui/components/command/GroupLabel.tsx create mode 100644 apps/extension/content/ui/components/command/Item.tsx diff --git a/apps/extension/content/ContentApp.tsx b/apps/extension/content/ContentApp.tsx index 66985047..54e7928a 100644 --- a/apps/extension/content/ContentApp.tsx +++ b/apps/extension/content/ContentApp.tsx @@ -21,6 +21,7 @@ import { useToast } from "./ui/shadcn/use-toast"; import { Input } from "./ui/shadcn/input"; import { Label } from "./ui/shadcn/label"; import { Textarea } from "./ui/shadcn/textarea"; +import ShowCommandMenu from "./showCommandMenu"; const BACKEND_URL = "https://supermemory.ai"; @@ -96,6 +97,52 @@ export default function ContentApp({ } }; + const [timer, setTimer] = useState(null); + const [progress, setProgress] = useState(0); + const timerRef = useRef(null); + + useEffect(() => { + if (isPopoverOpen && !timer) { + startTimer(); + } + }, [isPopoverOpen]); + + const startTimer = () => { + setProgress(0); + // @ts-ignore + timerRef.current = setInterval(() => { + setProgress((prev) => { + if (prev >= 100) { + clearInterval(timerRef.current!); + saveContent(); + return prev; + } + return prev + 5; + }); + }, 100); + }; + + const stopTimer = () => { + clearInterval(timerRef.current!); + setTimer(null); + }; + + const saveContent = async () => { + await sendUrlToAPI(selectedSpace ? [selectedSpace] : []); + }; + + const handleInputChange = ( + e: React.ChangeEvent, + ) => { + setWebNote(e.target.value); + stopTimer(); + }; + + const handleSelectChange = (value: string) => { + setSelectedSpace(value); + stopTimer(); + }; + useEffect(() => { document.addEventListener("mousemove", (e) => { const percentageX = (e.clientX / window.innerWidth) * 100; @@ -309,7 +356,10 @@ export default function ContentApp({ ) : (
-