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: ( + + {" "} + Creating memory... + + ), + success: (data) => "Memory queued", + error: (error) => `Memory creation failed: ${error}`, + richColors: true, + }); }; return ( @@ -190,23 +196,7 @@ function Menu() { -
{ - const content = e.get("content")?.toString(); - toast.promise(handleSubmit(content, selectedSpaces), { - loading: ( - - {" "} - Creating memory... - - ), - success: (data) => "Memory queued", - error: (error) => error.message, - richColors: true, - }); - }} - className="flex flex-col gap-4 " - > + Add memory @@ -227,17 +217,7 @@ function Menu() { onKeyDown={(e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); - toast.promise(handleSubmit(content, selectedSpaces), { - loading: ( - - {" "} - Creating memory... - - ), - success: (data) => "Memory created", - error: (error) => error.message, - richColors: true, - }); + formSubmit(); } }} />