fix: challange call
This commit is contained in:
@@ -263,6 +263,14 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (showChallengeDialog) {
|
||||
<div class="dialog-overlay" (click)="closeChallengeDialog()">
|
||||
<div class="dialog-card" (click)="$event.stopPropagation()">
|
||||
<app-challenge-create-dialog (closeChallengeDialog)="closeChallengeDialog()"></app-challenge-create-dialog>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (errorMessage) {
|
||||
<p class="error-banner">{{ errorMessage }}</p>
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ export class WelcomeComponent implements OnInit, OnDestroy {
|
||||
showOptionsDialog = false;
|
||||
showJoinDialog = false;
|
||||
showImportDialog = false;
|
||||
showChallengeDialog = false;
|
||||
|
||||
gameIdInput = '';
|
||||
importMode: ImportMode = 'fen';
|
||||
@@ -223,11 +224,21 @@ export class WelcomeComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
startOneVsOne(): void {
|
||||
if (!this.requireAuth(() => this.performStartOneVsOne())) {
|
||||
if (!this.requireAuth(() => this.openChallengeDialog())) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.performStartOneVsOne();
|
||||
this.openChallengeDialog();
|
||||
}
|
||||
|
||||
openChallengeDialog(): void {
|
||||
this.closeAllDialogs();
|
||||
this.showChallengeDialog = true;
|
||||
}
|
||||
|
||||
closeChallengeDialog(): void {
|
||||
this.showChallengeDialog = false;
|
||||
this.errorMessage = '';
|
||||
}
|
||||
|
||||
startVsBot(difficulty: Difficulty): void {
|
||||
@@ -352,28 +363,6 @@ export class WelcomeComponent implements OnInit, OnDestroy {
|
||||
action();
|
||||
}
|
||||
|
||||
private performStartOneVsOne(): void {
|
||||
if (this.creating) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.errorMessage = '';
|
||||
this.creating = true;
|
||||
|
||||
this.gameApi
|
||||
.createGame()
|
||||
.pipe(finalize(() => (this.creating = false)))
|
||||
.subscribe({
|
||||
next: (game) => {
|
||||
void this.router.navigate(['/game', game.gameId], {
|
||||
state: { theme: this.isSunsetMode ? 'light' : 'dark' }
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
this.errorMessage = getErrorMessage(error, 'Unable to create a game.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private performStartVsBot(difficulty: Difficulty): void {
|
||||
if (this.creating) {
|
||||
|
||||
Reference in New Issue
Block a user