diff options
| author | MohamedBassem <me@mbassem.com> | 2024-05-06 18:05:27 +0100 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-05-06 18:05:27 +0100 |
| commit | 32b5a025568dcc5788a8a2afc19bf07264e01a63 (patch) | |
| tree | 7ad808c667148154c9244cb3def56315da89ef52 /apps/web/components/dashboard | |
| parent | 02ef4bfc89e66fdf6593dd744aef53adee57b861 (diff) | |
| download | karakeep-32b5a025568dcc5788a8a2afc19bf07264e01a63.tar.zst | |
feature: Dedup links on creation. Fixes #49
Diffstat (limited to 'apps/web/components/dashboard')
| -rw-r--r-- | apps/web/components/dashboard/bookmarks/EditorCard.tsx | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/apps/web/components/dashboard/bookmarks/EditorCard.tsx b/apps/web/components/dashboard/bookmarks/EditorCard.tsx index f6ea0c9a..7c036c04 100644 --- a/apps/web/components/dashboard/bookmarks/EditorCard.tsx +++ b/apps/web/components/dashboard/bookmarks/EditorCard.tsx @@ -1,5 +1,6 @@ import type { SubmitErrorHandler, SubmitHandler } from "react-hook-form"; import { useEffect, useImperativeHandle, useRef } from "react"; +import Link from "next/link"; import { ActionButton } from "@/components/ui/action-button"; import { Form, FormControl, FormItem } from "@/components/ui/form"; import InfoTooltip from "@/components/ui/info-tooltip"; @@ -10,6 +11,7 @@ import { useClientConfig } from "@/lib/clientConfig"; import { useBookmarkLayoutSwitch } from "@/lib/userLocalSettings/bookmarksLayout"; import { cn } from "@/lib/utils"; import { zodResolver } from "@hookform/resolvers/zod"; +import { ExternalLink } from "lucide-react"; import { useForm } from "react-hook-form"; import { z } from "zod"; @@ -50,7 +52,23 @@ export default function EditorCard({ className }: { className?: string }) { useFocusOnKeyPress(inputRef); const { mutate, isPending } = useCreateBookmarkWithPostHook({ - onSuccess: () => { + onSuccess: (resp) => { + if (resp.alreadyExists) { + toast({ + description: ( + <div className="flex items-center gap-1"> + Bookmark already exists. + <Link + className="flex underline-offset-4 hover:underline" + href={`/dashboard/preview/${resp.id}`} + > + Open <ExternalLink className="ml-1 size-4" /> + </Link> + </div> + ), + variant: "default", + }); + } form.reset(); }, onError: () => { |
