From 77eaf330605a66ab0b86030f25a8b31be4e9b216 Mon Sep 17 00:00:00 2001 From: tobspr Date: Mon, 3 May 2021 15:59:23 +0200 Subject: [PATCH] Minor adjustments --- .../hud/parts/puzzle_complete_notification.js | 2 +- src/js/game/modes/puzzle_play.js | 39 ++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/js/game/hud/parts/puzzle_complete_notification.js b/src/js/game/hud/parts/puzzle_complete_notification.js index b9b523de..5941a1f3 100644 --- a/src/js/game/hud/parts/puzzle_complete_notification.js +++ b/src/js/game/hud/parts/puzzle_complete_notification.js @@ -130,7 +130,7 @@ export class HUDPuzzleCompleteNotification extends BaseHUDPart { report() { const mode = /** @type {PuzzlePlayGameMode} */ (this.root.gameMode); - mode.reportPuzzle(); + mode.reportPuzzle().then(() => this.close()); } updateState() { diff --git a/src/js/game/modes/puzzle_play.js b/src/js/game/modes/puzzle_play.js index da1f9dd4..e5f0da03 100644 --- a/src/js/game/modes/puzzle_play.js +++ b/src/js/game/modes/puzzle_play.js @@ -147,25 +147,28 @@ export class PuzzlePlayGameMode extends PuzzleGameMode { } ); - optionSelected.add(option => { - const closeLoading = this.root.hud.parts.dialogs.showLoadingDialog(); + return new Promise(resolve => { + optionSelected.add(option => { + const closeLoading = this.root.hud.parts.dialogs.showLoadingDialog(); - this.root.app.clientApi.apiReportPuzzle(this.puzzle.meta.id, option).then( - () => { - closeLoading(); - this.root.hud.parts.dialogs.showInfo( - T.dialogs.puzzleReportComplete.title, - T.dialogs.puzzleReportComplete.desc - ); - }, - err => { - closeLoading(); - this.root.hud.parts.dialogs.showInfo( - T.dialogs.puzzleReportError.title, - T.dialogs.puzzleReportError.desc + " " + err - ); - } - ); + this.root.app.clientApi.apiReportPuzzle(this.puzzle.meta.id, option).then( + () => { + closeLoading(); + const { ok } = this.root.hud.parts.dialogs.showInfo( + T.dialogs.puzzleReportComplete.title, + T.dialogs.puzzleReportComplete.desc + ); + ok.add(resolve); + }, + err => { + closeLoading(); + const { ok } = this.root.hud.parts.dialogs.showInfo( + T.dialogs.puzzleReportError.title, + T.dialogs.puzzleReportError.desc + " " + err + ); + } + ); + }); }); } }