aboutsummaryrefslogtreecommitdiff
path: root/apps/web
diff options
context:
space:
mode:
authorKush Thaker <[email protected]>2024-08-09 18:50:05 +0530
committerGitHub <[email protected]>2024-08-09 18:50:05 +0530
commited5ed419e184c56f7f09deb3eb733a8bbc1dc6c3 (patch)
treeee3e74b4e2b9ceb806625622b64e224c63b0c388 /apps/web
parentremove unwanted console logs (diff)
parentMerge pull request #236 from CodeTorso/queue (diff)
downloadsupermemory-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')
-rw-r--r--apps/web/app/(dash)/menu.tsx72
-rw-r--r--apps/web/app/layout.tsx2
-rw-r--r--apps/web/app/providers.tsx6
-rw-r--r--apps/web/wrangler.toml4
4 files changed, 31 insertions, 53 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",
diff --git a/apps/web/wrangler.toml b/apps/web/wrangler.toml
index a6232450..6062c8bf 100644
--- a/apps/web/wrangler.toml
+++ b/apps/web/wrangler.toml
@@ -26,8 +26,8 @@ bucket_name = "dev-r2-anycontext"
[[d1_databases]]
binding = "DATABASE"
-database_name = "dev-d1-anycontext"
-database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c"
+database_name = "prod-d1-supermemory"
+database_id = "f527a727-c472-41d4-8eaf-3d7ba0f2f395"
[[env.production.d1_databases]]
binding = "DATABASE"