Files
vpinball/lib/pinball/tableSelectionStore.ts
T

20 lines
739 B
TypeScript
Raw Normal View History

// In-memory handoff for the user's table choice between the landing page
// and /play — a File can't survive a URL-based navigation, and this is a
// single-shot value read once on mount, so module-level state is sufficient
// (no need for anything heavier than a plain variable).
export type PendingSelection =
| { kind: "upload"; vpxFile: File; romFile?: File; saveToLibrary: boolean }
| { kind: "library"; id: string };
let pendingSelection: PendingSelection | null = null;
export function setPendingTable(selection: PendingSelection): void {
pendingSelection = selection;
}
export function takePendingTable(): PendingSelection | null {
const selection = pendingSelection;
pendingSelection = null;
return selection;
}