Files
descrybe/apps/web/src/lib/cutover-readiness-poll.ts
T
greeneclipse 8580c996c3 Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
2026-08-09 22:47:43 +02:00

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;
}