Fix newgame bug (seek-cancel-seek should not create a game)
authorBenjamin Auder <benjamin.auder@somewhere>
Sat, 8 Dec 2018 14:14:41 +0000 (15:14 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sat, 8 Dec 2018 14:14:41 +0000 (15:14 +0100)
public/javascripts/components/game.js
sockets.js

index 1178b64..9ecba0c 100644 (file)
@@ -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;
                        }
index 452cb6e..ee4c1cf 100644 (file)
@@ -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);