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.

Update session when project slug changed

Steven Tey24a6e668d129
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 a6880833b8..af816d83c9 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
@@ -8,10 +8,12 @@ import { Form } from "@dub/ui";
import { useRouter } from "next/navigation";
import { toast } from "sonner";
import { mutate } from "swr";
+import { useSession } from "next-auth"
export default function WorkspaceSettingsClient() {
const router = useRouter();
const { id, name, slug, isOwner } = useWorkspace();
+ const { update } = useSession()
return (
<>
@@ -76,7 +78,10 @@ export default function WorkspaceSettingsClient() {
if (res.status === 200) {
const { slug: newSlug } = await res.json();
await mutate("/api/workspaces");
- router.push(`/${newSlug}/settings`);
+ if (newSlug != slug) {
+ router.push(`/${newSlug}/settings`);
+ update()
+ }
toast.success("Successfully updated workspace slug!");
} else {
const { error } = await res.json();