The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix archived domain edge case
Steven Tey46730c317fc5
diff --git a/apps/web/ui/modals/add-edit-link-modal/index.tsx b/apps/web/ui/modals/add-edit-link-modal/index.tsxindex fe318294b3..a0e9504e67 100644--- a/apps/web/ui/modals/add-edit-link-modal/index.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/index.tsx@@ -86,7 +86,6 @@ function AddEditLinkModal({aiLimit,mutate: mutateWorkspace,betaTester,- plan,} = useWorkspace();const [keyError, setKeyError] = useState<string | null>(null);@@ -94,7 +93,25 @@ function AddEditLinkModal({const [generatingRandomKey, setGeneratingRandomKey] = useState(false);const [saving, setSaving] = useState(false);- const { allActiveDomains: domains, primaryDomain, loading } = useDomains();+ const { allActiveDomains, primaryDomain, allDomains, loading } = useDomains();++ const domains = useMemo(() => {+ // edge case where the link's current domain has been archived+ if (+ props?.domain &&+ !allActiveDomains.find((domain) => domain.slug === props.domain)+ ) {+ const currentDomain = allDomains.find(+ (domain) => domain.slug === props.domain,+ );+ if (currentDomain) {+ return [...allActiveDomains, currentDomain].filter(Boolean);+ } else {+ return allActiveDomains;+ }+ }+ return allActiveDomains;+ }, [allDomains, allActiveDomains, props]);const [data, setData] = useState<LinkWithTagsProps>(props || duplicateProps || DEFAULT_LINK_PROPS,@@ -618,9 +635,12 @@ function AddEditLinkModal({"Only letters, numbers, '-', '/', and emojis are allowed.",);}}- onBlur={(e) =>- e.target.value && runKeyChecks(e.target.value)- }+ onBlur={(e) => {+ // if the key is changed, check if key exists+ if (e.target.value && props?.key !== e.target.value) {+ runKeyChecks(e.target.value);+ }+ }}disabled={props && lockKey}autoComplete="off"className={cn(