diff options
| author | Dhravya Shah <[email protected]> | 2025-02-14 15:53:44 -0800 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2025-02-14 15:53:44 -0800 |
| commit | af1093d4aab6d5654364e7cd9df76fd766bbee03 (patch) | |
| tree | f128bdb8cac4b44ed41289dc9a158c33fe86c5ec /apps/web/app/components | |
| parent | twitter import fix (diff) | |
| download | supermemory-af1093d4aab6d5654364e7cd9df76fd766bbee03.tar.xz supermemory-af1093d4aab6d5654364e7cd9df76fd766bbee03.zip | |
intuitive memory movement, avoid duplicates in home
Diffstat (limited to 'apps/web/app/components')
| -rw-r--r-- | apps/web/app/components/memories/SharedCard.tsx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/web/app/components/memories/SharedCard.tsx b/apps/web/app/components/memories/SharedCard.tsx index d80b848a..8e4c69b1 100644 --- a/apps/web/app/components/memories/SharedCard.tsx +++ b/apps/web/app/components/memories/SharedCard.tsx @@ -41,6 +41,7 @@ import { ExtraSpaceMetaData, fetchSpaces } from "~/lib/hooks/use-spaces"; import { useTextOverflow } from "~/lib/hooks/use-text-overflow"; import { Memory, WebsiteMetadata } from "~/lib/types/memory"; import { cn } from "~/lib/utils"; +import { useNavigate } from "@remix-run/react"; const { useTweet } = ReactTweet; @@ -616,6 +617,7 @@ export function FetchAndRenderContent({ content }: { content: string }) { function SharedCard({ data }: { data: Memory }) { const queryClient = useQueryClient(); + const navigate = useNavigate(); // Delete mutation const deleteMutation = useMutation({ @@ -657,7 +659,7 @@ function SharedCard({ data }: { data: Memory }) { // Move to space mutation const moveToSpaceMutation = useMutation({ mutationFn: async ({ spaceId, documentId }: { spaceId: string; documentId: string }) => { - const response = await fetch("/backend/v1/spaces/addContent", { + const response = await fetch("/backend/v1/spaces/moveContent", { method: "POST", headers: { "Content-Type": "application/json", @@ -668,15 +670,19 @@ function SharedCard({ data }: { data: Memory }) { if (!response.ok) { throw new Error("Failed to move memory"); } - return response.json(); + return response.json() as Promise<{ spaceId: string }>; }, onError: (err) => { toast.error("Failed to move memory to space"); }, - onSuccess: () => { + onSuccess: ({ spaceId }: { spaceId: string }) => { toast.success("Memory moved successfully"); queryClient.invalidateQueries({ queryKey: ["memories"] }); queryClient.invalidateQueries({ queryKey: ["spaces"] }); + if (spaceId === "<HOME>") { + return navigate("/"); + } + return navigate(`/space/${spaceId}`); }, }); |