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.

fixed mutate

Steven Teyf284399d9f00
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 a92fb96b12..ee0eb0a65c 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,10 +37,8 @@ export default function ProjectSettingsClient() {
body: JSON.stringify(updateData),
}).then(async (res) => {
if (res.status === 200) {
- await Promise.all([
- mutate("/api/projects"),
- mutate(`/api/projects/${slug}`),
- ]);
+ router.refresh();
+ await mutate(`/api/projects/${slug}`);
toast.success("Successfully updated project name!");
} else if (res.status === 422) {
toast.error("Project slug already exists");
@@ -76,6 +74,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!");
diff --git a/apps/web/ui/projects/upload-logo.tsx b/apps/web/ui/projects/upload-logo.tsx
index 1092688659..def90354f7 100644
--- a/apps/web/ui/projects/upload-logo.tsx
+++ b/apps/web/ui/projects/upload-logo.tsx
@@ -3,11 +3,12 @@
import useProject from "@/lib/swr/use-project";
import { Button } from "@dub/ui";
import { UploadCloud } from "lucide-react";
+import { useRouter } from "next/navigation";
import { useCallback, useEffect, useState } from "react";
import { toast } from "sonner";
-import { mutate } from "swr";
export default function UploadLogo() {
+ const router = useRouter();
const { slug, logo } = useProject();
const [image, setImage] = useState<string | null>();
@@ -53,10 +54,7 @@ export default function UploadLogo() {
body: JSON.stringify({ image }),
}).then(async (res) => {
if (res.status === 200) {
- await Promise.all([
- mutate(`/api/projects`),
- mutate(`/api/projects/${slug}`),
- ]);
+ router.refresh();
toast.success("Succesfully uploaded project logo!");
} else if (res.status === 413) {
toast.error("File size too big (max 2MB)");