Files
Jyotisha/frontend/src/lib/rectification-entry-summary-read.ts
T
Jesse_ChenandClaude Opus 5.5 ab656e0dea perf(home): cold boot reads account, people list, sessions and entry summary in one round (BUG-1127)
The sessions read guesses the remembered person and is dropped when the
people list settles on another; a first sign-in no longer re-reads the
people list it just fetched.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
2026-10-01 00:15:12 +08:00

27 lines
1.2 KiB
TypeScript

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<RectificationEntrySummary | null> | null = null;
export function startRectificationEntrySummaryRead(read: () => Promise<RectificationEntrySummary | null> = fetchRectificationEntrySummary): void {
pending = read().catch(() => null);
}
export function takeRectificationEntrySummary(read: () => Promise<RectificationEntrySummary | null> = fetchRectificationEntrySummary): Promise<RectificationEntrySummary | null> {
const started = pending;
pending = null;
return started ?? read();
}
export function resetRectificationEntrySummaryReadForTests(): void {
pending = null;
}