From 32b5a025568dcc5788a8a2afc19bf07264e01a63 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Mon, 6 May 2024 18:05:27 +0100
Subject: feature: Dedup links on creation. Fixes #49

---
 apps/mobile/app/dashboard/add-link.tsx | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'apps/mobile/app/dashboard/add-link.tsx')

diff --git a/apps/mobile/app/dashboard/add-link.tsx b/apps/mobile/app/dashboard/add-link.tsx
index d913ac01..5096a9e7 100644
--- a/apps/mobile/app/dashboard/add-link.tsx
+++ b/apps/mobile/app/dashboard/add-link.tsx
@@ -3,17 +3,24 @@ import { Text, View } from "react-native";
 import { useRouter } from "expo-router";
 import { Button } from "@/components/ui/Button";
 import { Input } from "@/components/ui/Input";
+import { useToast } from "@/components/ui/Toast";
 import { api } from "@/lib/trpc";
 
 export default function AddNote() {
   const [text, setText] = useState("");
   const [error, setError] = useState<string | undefined>();
+  const { toast } = useToast();
   const router = useRouter();
   const invalidateAllBookmarks =
     api.useUtils().bookmarks.getBookmarks.invalidate;
 
   const { mutate } = api.bookmarks.createBookmark.useMutation({
-    onSuccess: () => {
+    onSuccess: (resp) => {
+      if (resp.alreadyExists) {
+        toast({
+          message: "Bookmark already exists",
+        });
+      }
       invalidateAllBookmarks();
       if (router.canGoBack()) {
         router.replace("../");
-- 
cgit v1.2.3-70-g09d2

