X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=app.js;h=12c2b7ab65fea59a497ed1901a924889b0225491;hp=1090b30ce6c6f2545e775c156c76892387301b75;hb=HEAD;hpb=a5da62690c1314425a576302466b1d4ad406d80d diff --git a/app.js b/app.js index 1090b30..c5d5c7f 100644 --- a/app.js +++ b/app.js @@ -373,7 +373,7 @@ const messageCenter = (msg) => { if (document.hidden) notifyMe("move"); vr.playReceivedMove(obj.moves, () => { - if (vr.getCurrentScore(obj.moves[obj.moves.length-1]) != "*") { + if (vr.getCurrentScore(obj.moves) != "*") { localStorage.removeItem("gid"); setTimeout( () => toggleVisible("gameStopped"), 2000 ); } @@ -390,6 +390,10 @@ const messageCenter = (msg) => { case "closerematch": toggleVisible("newGame"); break; + case "filechange": + // TODO?: could be more subtle + setTimeout(() => location.reload(), 100); + break; } }; @@ -470,7 +474,6 @@ const afterPlay = (move_s, newTurn, ops) => { {gid: gid, moves: curMoves, fen: vr.getFen()}, { retry: true, - success: () => curMoves = [], error: () => alert("Move not sent: reload page") } ); @@ -478,7 +481,8 @@ const afterPlay = (move_s, newTurn, ops) => { } if (ops.res && newTurn != playerColor) { toggleTurnIndicator(false); //now all moves are sent and animated - const result = vr.getCurrentScore(move_s); + const result = vr.getCurrentScore(curMoves); + curMoves = []; if (result != "*") { setTimeout(() => { toggleVisible("gameStopped");