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.

mutate links count when you add/delete a link

Steven Tey0daf4131d9b1
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index 3685b8e993..393a998a51 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -291,6 +291,17 @@ function AddEditLinkModal({
? `/api/projects/${slug}/links${getQueryString(router)}`
: `/api/links${getQueryString(router)}`,
);
+ mutate(
+ (key) =>
+ typeof key === "string" &&
+ key.startsWith(
+ slug
+ ? `/api/projects/${slug}/links/count`
+ : `/api/links/count`,
+ ),
+ undefined,
+ { revalidate: true },
+ );
// for welcome page, redirect to links page after adding a link
if (router.asPath === "/welcome") {
router.push("/links").then(() => {
diff --git a/components/app/modals/delete-link-modal.tsx b/components/app/modals/delete-link-modal.tsx
index b306f381ef..e98251898e 100644
--- a/components/app/modals/delete-link-modal.tsx
+++ b/components/app/modals/delete-link-modal.tsx
@@ -81,6 +81,17 @@ function DeleteLinkModal({
? `/api/projects/${slug}/links${getQueryString(router)}`
: `/api/links${getQueryString(router)}`,
);
+ mutate(
+ (key) =>
+ typeof key === "string" &&
+ key.startsWith(
+ slug
+ ? `/api/projects/${slug}/links/count`
+ : `/api/links/count`,
+ ),
+ undefined,
+ { revalidate: true },
+ );
setShowDeleteLinkModal(false);
} else {
const { error } = await res.json();