import { fetchRectificationEntrySummary } from "./home-cloud-sync"; import type { RectificationEntrySummary } from "./rectification-entry"; /** * The home entry card summary, started with the other cold-boot reads instead * of after the session list (BUG-1127). The summary does not depend on the * session list; Home used to wait for it only because its effect was gated on * `sessionListSettled`. One read per cold boot: Home takes it once, and a * later call (account switch, retry) reads fresh. Failures read as null, which * keeps the card on its default labels, exactly as before. */ let pending: Promise | null = null; export function startRectificationEntrySummaryRead(read: () => Promise = fetchRectificationEntrySummary): void { pending = read().catch(() => null); } export function takeRectificationEntrySummary(read: () => Promise = fetchRectificationEntrySummary): Promise { const started = pending; pending = null; return started ?? read(); } export function resetRectificationEntrySummaryReadForTests(): void { pending = null; }