A seat link replaces a held seat only when the server refuses the held token, not when the connection drops, so a link cannot take a working seat away on a bad connection
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MbtUPJ24P6vc6tE1x6RS3m
This commit is contained in:
1 parent
21d9c12f48
commit
a673ea9766
1 file changed
+4
-2
@@ -4,7 +4,7 @@
|
|||||||
import Board from '$lib/components/Board.svelte';
|
import Board from '$lib/components/Board.svelte';
|
||||||
import ReportSlip from '$lib/components/ReportSlip.svelte';
|
import ReportSlip from '$lib/components/ReportSlip.svelte';
|
||||||
import TableTalk from '$lib/components/TableTalk.svelte';
|
import TableTalk from '$lib/components/TableTalk.svelte';
|
||||||
import { rememberSeat, seatFor, seatInLink, trustSeat, type HeldSeat } from '$lib/game/client';
|
import { rememberSeat, seatFor, seatInLink, ServerError, trustSeat, type HeldSeat } from '$lib/game/client';
|
||||||
import { COMPACT_QUERY, Duel, NAME_MAX, playerName } from '$lib/game/duel.svelte';
|
import { COMPACT_QUERY, Duel, NAME_MAX, playerName } from '$lib/game/duel.svelte';
|
||||||
|
|
||||||
const roomId = $derived((page.params.code ?? '').toUpperCase());
|
const roomId = $derived((page.params.code ?? '').toUpperCase());
|
||||||
@@ -88,8 +88,10 @@
|
|||||||
trustSeat(id);
|
trustSeat(id);
|
||||||
return remote;
|
return remote;
|
||||||
});
|
});
|
||||||
|
// Only the server's refusal of the held token lets a link in: a dropped connection is not a lost seat.
|
||||||
|
const refused = (e: unknown) => e instanceof ServerError && e.status === 403;
|
||||||
const arrive = held
|
const arrive = held
|
||||||
? Duel.resumeRoom(id, held).catch((e: Error) => (sent ? take(sent) : Promise.reject(e)))
|
? Duel.resumeRoom(id, held).catch((e: Error) => (sent && refused(e) ? take(sent) : Promise.reject(e)))
|
||||||
: sent
|
: sent
|
||||||
? take(sent).catch(() => Duel.watchRoom(id))
|
? take(sent).catch(() => Duel.watchRoom(id))
|
||||||
: Duel.watchRoom(id);
|
: Duel.watchRoom(id);
|
||||||
|
|||||||
Reference in new issue
Block a user