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

@@ -147,6 +147,7 @@ export class HostShellComponent implements OnInit {
if (this.session.session.status !== 'finished') {
this.resetFinalLeaderboard();
}
this.syncRouteFromSession();
} catch (error) {
this.error = `Session refresh failed: ${(error as Error).message}`;
} finally {
@@ -166,6 +167,7 @@ export class HostShellComponent implements OnInit {
this.roundQuestionId = this.session.round_question?.id ? String(this.session.round_question.id) : '';
this.scoreboardPayload = '';
this.resetFinalLeaderboard();
this.syncRouteFromSession();
});
}
@@ -263,6 +265,25 @@ export class HostShellComponent implements OnInit {
this.finalWinner = null;
}
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 = `#/host/${encodeURIComponent(phase)}/${encodeURIComponent(code)}`;
if (typeof window === 'undefined' || window.location.hash === targetPath) {
return;
}
window.history.replaceState(window.history.state, '', targetPath);
}
private async runAction(action: () => Promise<void>): Promise<void> {
this.loading = true;
this.error = '';