fix: NCWF-4 Token Issues (#8)

Co-authored-by: Lala, Shahd <Shahd.Lala@sybit.de>
Co-authored-by: shahdlala66 <shahd.lala66@gmail.com>
Reviewed-on: #8
This commit was merged in pull request #8.
This commit is contained in:
2026-06-02 21:55:55 +02:00
parent 873bfe3bae
commit 95eff42dfe
37 changed files with 2522 additions and 573 deletions
@@ -17,7 +17,8 @@
</svg>
Watch
</button>
<button type="button" class="nc-link">Leaderboard</button>
<button type="button" class="nc-link" (click)="goToTournaments()">Tournaments</button>
<button type="button" class="nc-link" (click)="goToBots()">Bots</button>
</div>
}
@@ -31,6 +31,7 @@ export class ToolbarComponent implements OnInit {
private readonly router = inject(Router);
private pollHandle: ReturnType<typeof setInterval> | null = null;
private readonly navigatedChallengeIds = new Set<string>();
currentUser: CurrentUser | null = null;
showLoginDialog = false;
@@ -55,6 +56,7 @@ export class ToolbarComponent implements OnInit {
} else {
this.challengeWs.disconnect();
this.stopPolling();
this.navigatedChallengeIds.clear();
this.challengeEventService.clear();
}
});
@@ -76,8 +78,8 @@ export class ToolbarComponent implements OnInit {
}
private startPolling(): void {
this.fetchIncoming();
this.pollHandle = setInterval(() => this.fetchIncoming(), 5000);
this.fetchChallenges();
this.pollHandle = setInterval(() => this.fetchChallenges(), 10_000);
}
private stopPolling(): void {
@@ -87,11 +89,21 @@ export class ToolbarComponent implements OnInit {
}
}
private fetchIncoming(): void {
private fetchChallenges(): void {
this.challengeService.listChallenges().subscribe({
next: response => {
const incoming = response.in ?? response.incoming ?? [];
this.challengeEventService.setIncomingChallenges(incoming);
const outgoing = response.out ?? response.outgoing ?? [];
for (const c of outgoing) {
if (c.status === 'accepted' && c.gameId && !this.navigatedChallengeIds.has(c.id)) {
this.navigatedChallengeIds.add(c.id);
if (!this.router.url.includes(`/game/${c.gameId}`)) {
void this.router.navigate(['/game', c.gameId]);
}
}
}
}
});
}
@@ -167,12 +179,24 @@ export class ToolbarComponent implements OnInit {
void this.router.navigate(['/games']);
}
goToTournaments(): void {
this.profileOpen = false;
this.notifOpen = false;
void this.router.navigate(['/tournaments']);
}
goToChallenges(): void {
this.profileOpen = false;
this.notifOpen = false;
void this.router.navigate(['/challenges']);
}
goToBots(): void {
this.profileOpen = false;
this.notifOpen = false;
void this.router.navigate(['/bots']);
}
onLoginSuccess(): void {
this.closeLoginDialog();
}