diff options
| author | Kush Thaker <[email protected]> | 2024-08-09 18:50:05 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-08-09 18:50:05 +0530 |
| commit | ed5ed419e184c56f7f09deb3eb733a8bbc1dc6c3 (patch) | |
| tree | ee3e74b4e2b9ceb806625622b64e224c63b0c388 /apps/web/app | |
| parent | remove unwanted console logs (diff) | |
| parent | Merge pull request #236 from CodeTorso/queue (diff) | |
| download | supermemory-kush/be-queue-fixes.tar.xz supermemory-kush/be-queue-fixes.zip | |
Merge branch 'main' into kush/be-queue-fixeskush/be-queue-fixes
Diffstat (limited to 'apps/web/app')
| -rw-r--r-- | apps/web/app/(dash)/menu.tsx | 72 | ||||
| -rw-r--r-- | apps/web/app/layout.tsx | 2 | ||||
| -rw-r--r-- | apps/web/app/providers.tsx | 6 |
3 files changed, 29 insertions, 51 deletions
diff --git a/apps/web/app/(dash)/menu.tsx b/apps/web/app/(dash)/menu.tsx index f9363efb..bdc1aa8a 100644 --- a/apps/web/app/(dash)/menu.tsx +++ b/apps/web/app/(dash)/menu.tsx @@ -31,10 +31,20 @@ import ComboboxWithCreate from "@repo/ui/shadcn/combobox"; import { StoredSpace } from "@repo/db/schema"; import useMeasure from "react-use-measure"; import { useKeyPress } from "@/lib/useKeyPress"; +import { useFormStatus } from "react-dom"; function Menu() { const [spaces, setSpaces] = useState<StoredSpace[]>([]); + function SubmitButton() { + const status = useFormStatus(); + return ( + <Button disabled={status.pending} variant={"secondary"} type="submit"> + Save {autoDetectedType != "none" && autoDetectedType} + </Button> + ); + } + useEffect(() => { (async () => { let spaces = await getSpaces(); @@ -120,15 +130,21 @@ function Menu() { }); setContent(""); setSelectedSpaces([]); - if (cont.success) { - toast.success("Memory queued", { - richColors: true, - }); - } else { - toast.error(`Memory creation failed: ${cont.error}`); - throw new Error(`Memory creation failed: ${cont.error}`); - return cont; - } + return cont; + }; + + const formSubmit = () => { + toast.promise(handleSubmit(content, selectedSpaces), { + loading: ( + <span> + <PlusCircleIcon className="w-4 h-4 inline mr-2 text-white animate-spin" />{" "} + Creating memory... + </span> + ), + success: (data) => "Memory queued", + error: (error) => `Memory creation failed: ${error}`, + richColors: true, + }); }; return ( @@ -180,23 +196,7 @@ function Menu() { </div> <DialogContent className="sm:max-w-[475px] text-[#F2F3F5] rounded-2xl bg-background z-[39]"> - <form - action={async (e: FormData) => { - const content = e.get("content")?.toString(); - toast.promise(handleSubmit(content, selectedSpaces), { - loading: ( - <span> - <PlusCircleIcon className="w-4 h-4 inline mr-2 text-white animate-spin" />{" "} - Creating memory... - </span> - ), - success: (data) => "Memory queued", - error: (error) => error.message, - richColors: true, - }); - }} - className="flex flex-col gap-4 " - > + <form action={formSubmit} className="flex flex-col gap-4 "> <DialogHeader> <DialogTitle>Add memory</DialogTitle> <DialogDescription className="text-[#F2F3F5]"> @@ -217,17 +217,7 @@ function Menu() { onKeyDown={(e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); - toast.promise(handleSubmit(content, selectedSpaces), { - loading: ( - <span> - <PlusCircleIcon className="w-4 h-4 inline mr-2 text-white animate-spin" />{" "} - Creating memory... - </span> - ), - success: (data) => "Memory created", - error: (error) => error.message, - richColors: true, - }); + formSubmit(); } }} /> @@ -319,13 +309,7 @@ function Menu() { </div> <DialogFooter> - <Button - disabled={autoDetectedType === "none"} - variant={"secondary"} - type="submit" - > - Save {autoDetectedType != "none" && autoDetectedType} - </Button> + <SubmitButton /> </DialogFooter> </form> </DialogContent> diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx index 28495d64..49805c16 100644 --- a/apps/web/app/layout.tsx +++ b/apps/web/app/layout.tsx @@ -86,7 +86,7 @@ export default function RootLayout({ > {children} <Toaster /> - <PostHogPageView /> + {/* <PostHogPageView /> */} </body> </PHProvider> </html> diff --git a/apps/web/app/providers.tsx b/apps/web/app/providers.tsx index f1f1237b..13e41647 100644 --- a/apps/web/app/providers.tsx +++ b/apps/web/app/providers.tsx @@ -4,12 +4,6 @@ import posthog from "posthog-js"; import { PostHogProvider } from "posthog-js/react"; if (typeof window !== "undefined") { - if ( - !process.env.NEXT_PUBLIC_POSTHOG_KEY || - !process.env.NEXT_PUBLIC_POSTHOG_HOST - ) { - console.error("PostHog key or host not found"); - } posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, { api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, person_profiles: "identified_only", |