The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add try/catch around auto copying after link creation
Tim Wilsonebafc30c5562
diff --git a/apps/web/ui/modals/add-edit-link-modal/index.tsx b/apps/web/ui/modals/add-edit-link-modal/index.tsxindex bea3a7e7de..adcc877c2e 100644--- a/apps/web/ui/modals/add-edit-link-modal/index.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/index.tsx@@ -353,14 +353,22 @@ function AddEditLinkModal({}// copy shortlink to clipboard when adding a new link (if document is focused)if (!props && document.hasFocus()) {- await navigator.clipboard.writeText(- linkConstructor({- // remove leading and trailing slashes- key: data.key.replace(/^\/+|\/+$/g, ""),- domain,- }),- );- toast.success("Copied shortlink to clipboard!");+ try {+ await navigator.clipboard.writeText(+ linkConstructor({+ // remove leading and trailing slashes+ key: data.key.replace(/^\/+|\/+$/g, ""),+ domain,+ }),+ );+ toast.success("Copied shortlink to clipboard!");+ } catch (e) {+ console.error(+ "Failed to automatically copy shortlink to clipboard.",+ e,+ );+ toast.success("Successfully created link!");+ }} else {toast.success("Successfully updated shortlink!");}