summaryrefslogtreecommitdiffstats
path: root/web/play/src
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-08 03:34:38 +0100
committersalmonik <salmonik@tuta.io>2026-11-08 03:34:38 +0100
commit408fac5c545c4294c81df5fff36b2fed19d7fe55 (patch)
treeef5a05d8099a1531f88cd3e5008225ea47910fc4 /web/play/src
parentweb: accept the serialized reels array and stop game loops on navigation (diff)
downloadzagan-bet-408fac5c545c4294c81df5fff36b2fed19d7fe55.tar.gz
zagan-bet-408fac5c545c4294c81df5fff36b2fed19d7fe55.zip
web: restore the balance on a refresh into history
The gateway hello now carries the core's last known balance alongside the user, so a refresh on a non-game view does not blank the header before the next INFO reply.
Diffstat (limited to '')
-rw-r--r--web/play/src/main.ts1
-rw-r--r--web/play/src/types.ts2
2 files changed, 3 insertions, 0 deletions
diff --git a/web/play/src/main.ts b/web/play/src/main.ts
index f051429..2dd3ce9 100644
--- a/web/play/src/main.ts
+++ b/web/play/src/main.ts
@@ -68,6 +68,7 @@ const gateway = new Gateway(wsUrl, {
68 onHello(hello) { 68 onHello(hello) {
69 serverOffset = hello.time - Date.now(); 69 serverOffset = hello.time - Date.now();
70 currentUser = hello.user ?? null; 70 currentUser = hello.user ?? null;
71 if (typeof hello.balance === "number") lastBalance = hello.balance;
71 gameBadge.textContent = `v${hello.version}`; 72 gameBadge.textContent = `v${hello.version}`;
72 }, 73 },
73 onView(next) { 74 onView(next) {
diff --git a/web/play/src/types.ts b/web/play/src/types.ts
index e594a0b..ae2c4c7 100644
--- a/web/play/src/types.ts
+++ b/web/play/src/types.ts
@@ -9,6 +9,8 @@ export type Hello = {
9 grace_seconds: number; 9 grace_seconds: number;
10 /** Signed-in user restored after a refresh, if any. */ 10 /** Signed-in user restored after a refresh, if any. */
11 user?: string | null; 11 user?: string | null;
12 /** Last known balance, for views that do not carry one. */
13 balance?: number | null;
12 /** Estimated game-server Unix time in milliseconds. */ 14 /** Estimated game-server Unix time in milliseconds. */
13 time: number; 15 time: number;
14}; 16};