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.

fix revalidation bugs

Steven Tey8ac84165079d
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-stats.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-stats.tsx
index 69408a2a5e..0aa0d1e5a4 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-stats.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-stats.tsx
@@ -11,7 +11,7 @@ export function CommissionStats() {
const { slug, programId } = useParams();
const { queryParams } = useRouterStuff();
const { commissionsCount, error } = useCommissionsCount({
- exclude: ["status"],
+ exclude: ["status", "page"],
});
return (
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-table.tsx
index 6d0281eae5..10e303037d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-table.tsx
@@ -60,21 +60,23 @@ const CommissionTableInner = memo(
sortOrder: "asc" | "desc";
};
- const { commissionsCount } = useCommissionsCount();
- const { data: commissions, error } = useSWR<CommissionResponse[]>(
- `/api/commissions${getQueryString(
- {
- workspaceId,
- programId,
- },
- {
- exclude: ["view"],
- },
- )}`,
+ const {
+ data: commissions,
+ error,
+ isLoading,
+ } = useSWR<CommissionResponse[]>(
+ `/api/commissions${getQueryString({
+ workspaceId,
+ programId,
+ })}`,
fetcher,
+ {
+ keepPreviousData: true,
+ },
);
-
- const loading = !commissions && !error;
+ const { commissionsCount } = useCommissionsCount({
+ exclude: ["status", "page"],
+ });
const table = useTable<CommissionResponse>({
data: commissions?.slice(0, limit) || [],
@@ -207,7 +209,7 @@ const CommissionTableInner = memo(
tdClassName: "border-l-0",
resourceName: (p) => `commission${p ? "s" : ""}`,
rowCount: commissionsCount?.[searchParamsObj.status || "all"].count ?? 0,
- loading,
+ loading: isLoading,
error: error ? "Failed to load commissions" : undefined,
});
@@ -254,7 +256,7 @@ const CommissionTableInner = memo(
</AnimatedSizeContainer>
</div>
)}
- {commissions?.length !== 0 ? (
+ {commissions?.length !== 0 || isLoading ? (
<Table {...table} />
) : (
<AnimatedEmptyState
diff --git a/apps/web/lib/swr/use-commissions-count.ts b/apps/web/lib/swr/use-commissions-count.ts
index 5181d993d7..4dae0125fa 100644
--- a/apps/web/lib/swr/use-commissions-count.ts
+++ b/apps/web/lib/swr/use-commissions-count.ts
@@ -18,10 +18,13 @@ export default function useCommissionsCount(opts?: Record<string, any>) {
},
{
...opts,
- exclude: ["view", ...(opts?.exclude || [])],
+ exclude: opts?.exclude || [],
},
)}`,
fetcher,
+ {
+ keepPreviousData: true,
+ },
);
return {
diff --git a/apps/web/lib/swr/use-partners-count.ts b/apps/web/lib/swr/use-partners-count.ts
index c9450e839c..d3e7277706 100644
--- a/apps/web/lib/swr/use-partners-count.ts
+++ b/apps/web/lib/swr/use-partners-count.ts
@@ -44,6 +44,9 @@ export default function usePartnersCount<T>({
const { data: partnersCount, error } = useSWR<PartnersCount>(
enabled !== false ? `/api/partners/count${queryString}` : null,
fetcher,
+ {
+ keepPreviousData: true,
+ },
);
return {