feat(spa): sync host/player hash phase routes during gameplay
All checks were successful
CI / test-and-quality (push) Successful in 2m26s
CI / test-and-quality (pull_request) Successful in 2m35s

This commit is contained in:
2026-03-01 18:54:19 +00:00
parent 778b8e2817
commit fcfb3b21b1
4 changed files with 94 additions and 2 deletions

View File

@@ -296,6 +296,25 @@ export class PlayerShellComponent implements OnInit, OnDestroy {
});
}
private syncRouteFromSession(): void {
if (!this.session) {
return;
}
const phase = this.session.session.status || 'lobby';
const code = this.normalizeCode(this.session.session.code || this.sessionCode);
if (!code) {
return;
}
const targetPath = `#/player/${encodeURIComponent(phase)}/${encodeURIComponent(code)}`;
if (typeof window === 'undefined' || window.location.hash === targetPath) {
return;
}
window.history.replaceState(window.history.state, '', targetPath);
}
private async request<T>(path: string, method: 'GET' | 'POST', payload?: unknown): Promise<T> {
const response = await fetch(path, {
method,
@@ -330,6 +349,7 @@ export class PlayerShellComponent implements OnInit, OnDestroy {
this.selectedGuess = '';
}
this.syncFinalLeaderboard();
this.syncRouteFromSession();
this.markOnline();
} catch (error) {
this.error = `Session refresh failed: ${this.toMessage(error)}`;
@@ -359,6 +379,7 @@ export class PlayerShellComponent implements OnInit, OnDestroy {
this.selectedGuess = '';
}
this.syncFinalLeaderboard();
this.syncRouteFromSession();
this.markOnline();
} catch (error) {
this.error = `Join failed: ${this.toMessage(error)}`;