29 lines
804 B
TypeScript
29 lines
804 B
TypeScript
/** Shared poll policy for platform-admin cutover readiness (P1-15). */
|
|||
|
|
|
||
|
|
/** Interval between completed (non-abort) readiness fetches while polling. */
|
||
|
|
export const CUTOVER_READINESS_POLL_MS = 60_000;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Decide whether to hit GET /api/admin/readiness.
|
||
|
|
* Dedupes in-flight + enforces a min interval so layout effect remounts cannot hammer the API.
|
||
|
|
*/
|
||
|
|
export function shouldRunCutoverReadinessFetch(input: {
|
||
|
|
nowMs: number;
|
||
|
|
lastAttemptAtMs: number;
|
||
|
|
minIntervalMs: number;
|
||
|
|
documentVisible: boolean;
|
||
|
|
inFlight: boolean;
|
||
|
|
force?: boolean;
|
||
|
|
}): boolean {
|
||
|
|
if (!input.documentVisible) return false;
|
||
|
|
if (input.inFlight) return false;
|
||
|
|
if (input.force) return true;
|
||
|
|
if (
|
||
|
|
input.lastAttemptAtMs > 0 &&
|
||
|
|
input.nowMs - input.lastAttemptAtMs < input.minIntervalMs
|
||
|
|
) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|