From 283d06a4401a937d602c4b863201945f1be3e701 Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Sat, 8 Dec 2018 15:14:41 +0100 Subject: [PATCH] Fix newgame bug (seek-cancel-seek should not create a game) --- public/javascripts/components/game.js | 1 + sockets.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 1178b64a..9ecba0cb 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -667,6 +667,7 @@ Vue.component('my-game', { return; //no newgame while playing if (this.seek) { + this.conn.send(JSON.stringify({code:"cancelnewgame"})); delete localStorage["newgame"]; //cancel game seek this.seek = false; } diff --git a/sockets.js b/sockets.js index 452cb6e0..ee4c1cfd 100644 --- a/sockets.js +++ b/sockets.js @@ -88,6 +88,9 @@ module.exports = function(wss) { else games[page] = {id:sid, fen:obj.fen}; //wait for opponent break; + case "cancelnewgame": //if a user cancel his seek + delete games[page]; + break; case "resign": if (!!clients[page][obj.oppid]) clients[page][obj.oppid].send(JSON.stringify({code:"resign"}), noop); -- 2.44.0