fix(chat): don't restore unread on a failed read-ack (would loop the in-game effect; REST re-seed self-heals)
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 49s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 59s

This commit is contained in:
Ilia Denisov
2026-06-17 11:14:25 +02:00
parent aaac816dc2
commit a7f3df9346
+5 -4
View File
@@ -166,14 +166,15 @@ export function seedChatUnread(gameId: string, unread: boolean): void {
* markChatRead clears a game's unread badge and tells the backend the player has read the chat — * markChatRead clears a game's unread badge and tells the backend the player has read the chat —
* called when the move history or the chat opens. It hits the backend only when something is * called when the move history or the chat opens. It hits the backend only when something is
* actually unread, so opening the history does not call the backend on every tap. The clear is * actually unread, so opening the history does not call the backend on every tap. The clear is
* optimistic; a failed ack restores the badge so a later open retries. * optimistic and the ack is best-effort: a failed ack leaves the server bit set, which the next
* authoritative REST view (lobby list / game state) re-seeds, so the badge self-heals — it is
* deliberately not restored here, since the in-game effect re-runs while the history is shown and
* a restore would loop on a persistently failing ack.
*/ */
export function markChatRead(gameId: string): void { export function markChatRead(gameId: string): void {
if (!app.chatUnread[gameId]) return; if (!app.chatUnread[gameId]) return;
app.chatUnread = { ...app.chatUnread, [gameId]: false }; app.chatUnread = { ...app.chatUnread, [gameId]: false };
void gateway.markChatRead(gameId).catch(() => { void gateway.markChatRead(gameId).catch(() => {});
app.chatUnread = { ...app.chatUnread, [gameId]: true };
});
} }
/** handleError maps a GatewayError to a toast; an invalid session logs out. A connectivity /** handleError maps a GatewayError to a toast; an invalid session logs out. A connectivity