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.

add mutate

Steven Teyb551f1bcb898
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx
index 2aadca16ce..a92fb96b12 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx
@@ -37,8 +37,10 @@ export default function ProjectSettingsClient() {
body: JSON.stringify(updateData),
}).then(async (res) => {
if (res.status === 200) {
- router.refresh();
- await mutate(`/api/projects/${slug}`);
+ await Promise.all([
+ mutate("/api/projects"),
+ mutate(`/api/projects/${slug}`),
+ ]);
toast.success("Successfully updated project name!");
} else if (res.status === 422) {
toast.error("Project slug already exists");
@@ -74,7 +76,7 @@ export default function ProjectSettingsClient() {
}).then(async (res) => {
if (res.status === 200) {
const { slug: newSlug } = await res.json();
- router.refresh();
+ await mutate("/api/projects");
router.push(`/${newSlug}/settings`);
toast.success("Successfully updated project slug!");
} else if (res.status === 422) {
diff --git a/apps/web/ui/modals/accept-invite-modal.tsx b/apps/web/ui/modals/accept-invite-modal.tsx
index bc992af08a..9a2fdf49df 100644
--- a/apps/web/ui/modals/accept-invite-modal.tsx
+++ b/apps/web/ui/modals/accept-invite-modal.tsx
@@ -56,9 +56,9 @@ function AcceptInviteModal({
project: slug,
});
await Promise.all([
+ mutate("/api/projects"),
mutate(`/api/projects/${slug}`),
mutate(`/api/projects/${slug}/domains`),
- router.refresh(),
]);
setShowAcceptInviteModal(false);
toast.success("You now are a part of this project!");
diff --git a/apps/web/ui/modals/add-project-modal.tsx b/apps/web/ui/modals/add-project-modal.tsx
index d09adc9065..77920a4626 100644
--- a/apps/web/ui/modals/add-project-modal.tsx
+++ b/apps/web/ui/modals/add-project-modal.tsx
@@ -112,7 +112,7 @@ function AddProjectModalHelper({
if (res.status === 200) {
// track project creation event
va.track("Created Project");
- router.refresh();
+ await mutate("/api/projects");
if (welcomeFlow) {
router.push(`/welcome?type=upgrade&slug=${slug}`);
} else {
diff --git a/apps/web/ui/modals/delete-project-modal.tsx b/apps/web/ui/modals/delete-project-modal.tsx
index 6227c64cdb..94c47c0c34 100644
--- a/apps/web/ui/modals/delete-project-modal.tsx
+++ b/apps/web/ui/modals/delete-project-modal.tsx
@@ -36,7 +36,7 @@ function DeleteProjectModal({
},
}).then(async (res) => {
if (res.ok) {
- router.refresh();
+ await mutate("/api/projects");
router.push("/");
resolve(null);
} else {
diff --git a/apps/web/ui/modals/remove-teammate-modal.tsx b/apps/web/ui/modals/remove-teammate-modal.tsx
index 380b263efd..5ab3f4dd46 100644
--- a/apps/web/ui/modals/remove-teammate-modal.tsx
+++ b/apps/web/ui/modals/remove-teammate-modal.tsx
@@ -103,7 +103,7 @@ function RemoveTeammateModal({
`/api/projects/${slug}/${invite ? "invites" : "users"}`,
);
if (session?.user?.email === email) {
- router.refresh();
+ await mutate("/api/projects");
router.push("/");
} else {
setShowRemoveTeammateModal(false);
diff --git a/apps/web/ui/projects/upload-logo.tsx b/apps/web/ui/projects/upload-logo.tsx
index 28cdd2eade..1cc4efdeaf 100644
--- a/apps/web/ui/projects/upload-logo.tsx
+++ b/apps/web/ui/projects/upload-logo.tsx
@@ -55,8 +55,10 @@ export default function UploadLogo() {
body: JSON.stringify({ image }),
}).then(async (res) => {
if (res.status === 200) {
- router.refresh();
- await mutate(`/api/projects/${slug}`);
+ await Promise.all([
+ mutate("/api/projects"),
+ mutate(`/api/projects/${slug}`),
+ ]);
toast.success("Succesfully uploaded project logo!");
} else if (res.status === 413) {
toast.error("File size too big (max 2MB)");