diff options
| author | Dhravya Shah <[email protected]> | 2024-08-08 14:21:00 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-08-08 14:21:00 -0700 |
| commit | b056f2cb0da11fc3ff6a26fba71e88c3ae0bb49f (patch) | |
| tree | fdc1846020c8b1225836a0d84f54e10ca0a2b09a | |
| parent | Update README.md (diff) | |
| parent | one more commit needed (diff) | |
| download | supermemory-b056f2cb0da11fc3ff6a26fba71e88c3ae0bb49f.tar.xz supermemory-b056f2cb0da11fc3ff6a26fba71e88c3ae0bb49f.zip | |
Merge pull request #236 from CodeTorso/queue
memory queue fix
| -rw-r--r-- | apps/web/app/(dash)/menu.tsx | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/apps/web/app/(dash)/menu.tsx b/apps/web/app/(dash)/menu.tsx index b8bd25cc..bdc1aa8a 100644 --- a/apps/web/app/(dash)/menu.tsx +++ b/apps/web/app/(dash)/menu.tsx @@ -130,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 ( @@ -190,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]"> @@ -227,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(); } }} /> |