From 32b5a025568dcc5788a8a2afc19bf07264e01a63 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Mon, 6 May 2024 18:05:27 +0100 Subject: feature: Dedup links on creation. Fixes #49 --- apps/mobile/app/sharing.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'apps/mobile/app/sharing.tsx') 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 = Hoarded!; break; } + case "alreadyExists": { + comp = Already Hoarded!; + break; + } case "error": { comp = Error!; break; -- cgit v1.2.3-70-g09d2