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.

fix: save option enabled for new tags and update link-preview on url change

{Suksham-sharma}f5b50d732a05
diff --git a/apps/web/ui/modals/link-builder/tag-select.tsx b/apps/web/ui/modals/link-builder/tag-select.tsx
index 48fbdd40bd..b29efc9e77 100644
--- a/apps/web/ui/modals/link-builder/tag-select.tsx
+++ b/apps/web/ui/modals/link-builder/tag-select.tsx
@@ -71,7 +71,7 @@ export function TagSelect() {
if (res.ok) {
const newTag = await res.json();
- setValue("tags", [...tags, newTag]);
+ setValue("tags", [...tags, newTag], { shouldDirty: true });
toast.success(`Successfully created tag!`);
setIsOpen(false);
await mutate(`/api/tags?workspaceId=${workspaceId}`);
diff --git a/apps/web/ui/modals/link-builder/use-metatags.ts b/apps/web/ui/modals/link-builder/use-metatags.ts
index e25bf6bc68..1a66bd4493 100644
--- a/apps/web/ui/modals/link-builder/use-metatags.ts
+++ b/apps/web/ui/modals/link-builder/use-metatags.ts
@@ -46,10 +46,14 @@ export function useMetatags({
fetch(`/api/metatags?url=${debouncedUrl}`).then(async (res) => {
if (res.status === 200) {
const results = await res.json();
- if (!title) setValue("title", truncate(results.title, 120));
- if (!description)
- setValue("description", truncate(results.description, 240));
- if (!image) setValue("image", results.image);
+ const truncatedTitle = truncate(results.title, 120);
+ const truncatedDescription = truncate(results.description, 240);
+ if (title !== truncatedTitle) {
+ setValue("title", truncatedTitle);
+ }
+ if (description !== truncatedDescription)
+ setValue("description", truncatedDescription);
+ if (image !== results.image) setValue("image", results.image);
}
// set timeout to prevent flickering
setTimeout(() => setGeneratingMetatags(false), 200);