From: Benjamin Auder Date: Mon, 25 Jan 2021 20:48:57 +0000 (+0100) Subject: Fix corr game rematch X-Git-Url: https://git.auder.net/css/vendor/img/scripts/assets/%24%7BgetWhatsApp%28link%29%7D?a=commitdiff_plain;h=9f9e9a0588d4b28a1825a56ae53553d89bf0c65f;p=vchess.git Fix corr game rematch --- diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index c2b27043..6aea261e 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -1056,8 +1056,7 @@ export default { cadence: this.game.cadence }; const notifyNewGame = () => { - const oppsid = this.getOppsid(); //may be null - this.send("rnewgame", { data: gameInfo, oppsid: oppsid }); + this.send("rnewgame", { data: gameInfo }); // To main Hall if corr game: if (this.game.type == "corr") this.send("newgame", { data: gameInfo, page: "/" }); @@ -1065,6 +1064,10 @@ export default { this.notifyMyGames("newgame", gameInfo); }; if (this.game.type == "live") { + GameStorage.update( + this.gameRef, + { rematchOffer: "" } + ); // Increment game stats counter in DB ajax( "/gamestat", @@ -1075,15 +1078,16 @@ export default { } else { // corr game + this.updateCorrGame({ rematchOffer: 'n' }); ajax( "/games", "POST", { data: { gameInfo: gameInfo }, success: (response) => { - gameInfo.id = response.gameId; + gameInfo.id = response.id; notifyNewGame(); - this.$router.push("/game/" + response.gameId); + this.$router.push("/game/" + response.id); } } ); diff --git a/server/models/Game.js b/server/models/Game.js index 4a8c517a..e6c26168 100644 --- a/server/models/Game.js +++ b/server/models/Game.js @@ -85,9 +85,10 @@ const GameModel = { let query = "SELECT " + "g.id, g.fen, g.fenStart, g.cadence, g.created, " + - "g.white, g.black, g.score, g.scoreMsg, " + - "g.chatReadWhite, g.chatReadBlack, " + - "g.drawOffer, g.rematchOffer, v.name AS vname " + + "g.white, g.black, g.randomness, g.score, g.scoreMsg, " + + "g.chatReadWhite, g.chatReadBlack, g.drawOffer, " + + // TODO: vid and vname are redundant + "g.rematchOffer, v.id as vid, v.name AS vname " + "FROM Games g " + "JOIN Variants v " + " ON g.vid = v.id " +