diff --git a/packages/web/src/net.svelte.ts b/packages/web/src/net.svelte.ts index d8b278f..ffb1ada 100644 --- a/packages/web/src/net.svelte.ts +++ b/packages/web/src/net.svelte.ts @@ -350,8 +350,20 @@ export function attentionLabel(a: GameSummary["attention"]): string { } function loadSeats(): Seat[] { - try { return JSON.parse(localStorage.getItem(SEATS_KEY) ?? "[]"); } - catch { return []; } + let seats: Seat[]; + try { seats = JSON.parse(localStorage.getItem(SEATS_KEY) ?? "[]"); } + catch { seats = []; } + // The seat last sat in is kept on its own as well. A wallet that lost + // it (a cap that once dropped the newest seat) takes it back from there. + try { + const last = JSON.parse(localStorage.getItem(SEAT_KEY) ?? "null") as Seat | null; + if (last?.roomId && last.name && last.token && + !seats.some((s) => s.roomId === last.roomId && s.name === last.name)) { + seats = [last, ...seats]; + saveSeats(seats); + } + } catch { /* an unreadable last seat adds nothing */ } + return seats; } function saveSeats(seats: Seat[]): void { localStorage.setItem(SEATS_KEY, JSON.stringify(seats));