diff options
Diffstat (limited to 'apps/mobile/app')
| -rw-r--r-- | apps/mobile/app/dashboard/add-link.tsx | 9 | ||||
| -rw-r--r-- | apps/mobile/app/sharing.tsx | 12 |
2 files changed, 18 insertions, 3 deletions
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("../"); diff --git a/apps/mobile/app/sharing.tsx b/apps/mobile/app/sharing.tsx index 7624474a..7339a017 100644 --- a/apps/mobile/app/sharing.tsx +++ b/apps/mobile/app/sharing.tsx @@ -12,12 +12,16 @@ import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; type Mode = | { type: "idle" } | { type: "success"; bookmarkId: string } + | { type: "alreadyExists"; bookmarkId: string } | { type: "error" }; function SaveBookmark({ setMode }: { setMode: (mode: Mode) => void }) { - const onSaved = (d: ZBookmark) => { + const onSaved = (d: ZBookmark & { alreadyExists: boolean }) => { invalidateAllBookmarks(); - setMode({ type: "success", bookmarkId: d.id }); + setMode({ + type: d.alreadyExists ? "alreadyExists" : "success", + bookmarkId: d.id, + }); }; const { hasShareIntent, shareIntent, resetShareIntent } = @@ -86,6 +90,10 @@ export default function Sharing() { comp = <Text className="text-4xl text-foreground">Hoarded!</Text>; break; } + case "alreadyExists": { + comp = <Text className="text-4xl text-foreground">Already Hoarded!</Text>; + break; + } case "error": { comp = <Text className="text-4xl text-foreground">Error!</Text>; break; |
