645a503532
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 10s
CI / ui (pull_request) Successful in 27s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m4s
31 lines
979 B
TypeScript
31 lines
979 B
TypeScript
// In-memory lobby snapshot, the lobby counterpart of gamecache.ts. The lobby re-fetches
|
|
// its lists on every entry, so without a cache the screen renders blank and "draws in"
|
|
// during the back-slide from a game. Caching the last lists lets the lobby render
|
|
// instantly (before/under the transition) and refresh in the background. Process-memory
|
|
// only; cleared on logout.
|
|
|
|
import type { AccountRef, GameView, Invitation } from './model';
|
|
|
|
interface LobbySnapshot {
|
|
games: GameView[];
|
|
invitations: Invitation[];
|
|
incoming: AccountRef[];
|
|
}
|
|
|
|
let snapshot: LobbySnapshot | null = null;
|
|
|
|
/** getLobby returns the last lobby lists, or null before the first load. */
|
|
export function getLobby(): LobbySnapshot | null {
|
|
return snapshot;
|
|
}
|
|
|
|
/** setLobby stores the latest lobby lists. */
|
|
export function setLobby(s: LobbySnapshot): void {
|
|
snapshot = s;
|
|
}
|
|
|
|
/** clearLobby drops the cached lobby (called on logout). */
|
|
export function clearLobby(): void {
|
|
snapshot = null;
|
|
}
|