fix: api streaming issues
This commit is contained in:
@@ -158,9 +158,10 @@
|
||||
<div class="state-msg small"><span class="pulse"></span>Loading…</div>
|
||||
} @else if (pairings && pairings.pairings.length > 0) {
|
||||
<div class="pairings-list">
|
||||
@for (p of pairings.pairings; track p.id) {
|
||||
<div class="pairing-row" [class.is-watchable]="!!p.gameId"
|
||||
(click)="p.gameId && watchGame(p.gameId)">
|
||||
@for (p of pairings.pairings; track pairingKey(p)) {
|
||||
@let gid = firstGameId(p);
|
||||
<div class="pairing-row" [class.is-watchable]="!!gid"
|
||||
(click)="gid && watchGame(gid)">
|
||||
<span class="pairing-white">{{ p.white?.name ?? 'Bye' }}</span>
|
||||
<span class="pairing-vs">vs</span>
|
||||
<span class="pairing-black">{{ p.black.name }}</span>
|
||||
@@ -168,7 +169,7 @@
|
||||
<span class="pairing-result" [class]="'result-' + p.winner">
|
||||
{{ p.winner === 'draw' ? '½–½' : p.winner === 'white' ? '1–0' : '0–1' }}
|
||||
</span>
|
||||
} @else if (p.gameId) {
|
||||
} @else if (gid) {
|
||||
<span class="pairing-ongoing">
|
||||
<svg width="9" height="9" viewBox="0 0 24 24" fill="currentColor">
|
||||
<circle cx="12" cy="12" r="10"/>
|
||||
|
||||
@@ -10,7 +10,7 @@ import { BotService } from '../../services/bot.service';
|
||||
import { OfficialBotService } from '../../services/official-bot.service';
|
||||
import { TournamentServerService, ExternalTournamentServer } from '../../services/tournament-server.service';
|
||||
import { Bot } from '../../models/bot.models';
|
||||
import { Tournament, TournamentResult, RoundPairings } from '../../models/tournament.models';
|
||||
import { Tournament, TournamentResult, RoundPairings, TournamentPairing } from '../../models/tournament.models';
|
||||
import { CurrentUser } from '../../models/auth.models';
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
@@ -167,6 +167,16 @@ export class TournamentsComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
firstGameId(p: TournamentPairing): string | null {
|
||||
return p.matches?.[0]?.gameId ?? null;
|
||||
}
|
||||
|
||||
pairingKey(p: TournamentPairing): string {
|
||||
const w = p.white?.id ?? 'bye';
|
||||
const b = p.black?.id ?? 'bye';
|
||||
return `${w}-${b}-${this.firstGameId(p) ?? ''}`;
|
||||
}
|
||||
|
||||
watchGame(gameId: string): void {
|
||||
const tid = this.selectedTournament?.id;
|
||||
if (!tid) return;
|
||||
|
||||
Reference in New Issue
Block a user