Dedup checkout status refetch and in-flight requests

This commit is contained in:
Mohamed Boudra
2026-01-23 15:46:44 +07:00
parent eab8713c24
commit 907b9f9fbd
5 changed files with 285 additions and 19 deletions
@@ -0,0 +1,23 @@
export type CheckoutStatusRevalidationParams = {
serverId: string;
agentId: string;
isOpen: boolean;
explorerTab: string;
};
export function checkoutStatusRevalidationKey(params: CheckoutStatusRevalidationParams): string | null {
if (!params.agentId) return null;
if (!params.isOpen) return null;
if (params.explorerTab !== "changes") return null;
return `${params.serverId}:${params.agentId}`;
}
export function nextCheckoutStatusRefetchDecision(
prevKey: string | null,
nextKey: string | null
): { nextSeenKey: string | null; shouldRefetch: boolean } {
if (!nextKey) return { nextSeenKey: null, shouldRefetch: false };
if (prevKey === nextKey) return { nextSeenKey: prevKey, shouldRefetch: false };
return { nextSeenKey: nextKey, shouldRefetch: true };
}