Skip to content

Commit

Permalink
improve swr revalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Oct 20, 2024
1 parent 565538a commit 484b09b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 2 additions & 6 deletions apps/web/ui/domains/register-domain-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,13 @@ export function RegisterDomainForm({
} else {
toast.success("Domain registered successfully!");

// Mutate workspace, domains links
// Mutate workspace, domains, and links
await Promise.all([
mutate(`/api/workspaces/${workspace.slug}`),
mutate(
(key) =>
typeof key === "string" &&
(key.startsWith(`/api/domains?workspaceId=${workspace.id}`) ||
key.startsWith(`/api/domains/count?workspaceId=${workspace.id}`)),
),
mutate(
(key) => typeof key === "string" && key.startsWith("/api/links"),
(key.startsWith("/api/domains") || key.startsWith("/api/links")),
undefined,
{ revalidate: true },
),
Expand Down
5 changes: 3 additions & 2 deletions apps/web/ui/modals/delete-domain-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ function DeleteDomainModal({
if (res.status === 200) {
await mutate(
(key) =>
typeof key === "string" &&
key.startsWith(`/api/domains?workspaceId=${id}`),
typeof key === "string" && key.startsWith("/api/domains"),
undefined,
{ revalidate: true },
);
setShowDeleteDomainModal(false);
toast.success("Successfully deleted domain!");
Expand Down

0 comments on commit 484b09b

Please sign in to comment.