Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Auto copy shortlink to clipboard when creating a new link

Steven Tey59741598ca25
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index b9525a10fd..f0f4798d62 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -38,6 +38,7 @@ import IOSSection from "./ios-section";
import Preview from "./preview";
import AndroidSection from "./android-section";
import { DEFAULT_LINK_PROPS } from "@/lib/constants";
+import { toast } from "react-hot-toast";
function AddEditLinkModal({
showAddEditLinkModal,
@@ -281,6 +282,19 @@ function AddEditLinkModal({
setShowAddEditLinkModal(false);
});
} else {
+ // copy shortlink to clipboard when adding a new link
+ if (!props) {
+ navigator.clipboard
+ .writeText(
+ linkConstructor({
+ key: data.key,
+ domain,
+ }),
+ )
+ .then(() => {
+ toast.success("Copied shortlink to clipboard");
+ });
+ }
setShowAddEditLinkModal(false);
}
} else if (res.status === 403) {