From: Benjamin Auder Date: Thu, 5 Mar 2020 17:16:04 +0000 (+0100) Subject: Fxing attempt. Still not satisfactory X-Git-Url: https://git.auder.net/variants/Chakart/css/doc/index.css?a=commitdiff_plain;h=d6f08e5642e0bdbe3805ffd1a155ecc753178d1e;p=vchess.git Fxing attempt. Still not satisfactory --- diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index bbbb6760..fbdf4e63 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -241,6 +241,22 @@ export default { (color == "b" && movesCount % 2 == 1); this.send("turnchange", { target: sid, yourTurn: yourTurn }); }, + askGameAgain: function() { + this.gameIsLoading = true; + if (!this.gameRef.rid) + // This is my game: just reload. + this.loadGame(); + else { + // Just ask fullgame again (once!), this is much simpler. + // If this fails, the user could just reload page :/ + let self = this; + (function askIfPeerConnected() { + if (!!self.people[self.gameRef.rid]) + self.send("askfullgame", { target: self.gameRef.rid }); + else setTimeout(askIfPeerConnected, 1000); + })(); + } + }, socketMessageListener: function(msg) { if (!this.conn) return; const data = JSON.parse(msg.data); @@ -399,23 +415,10 @@ export default { const movesCount = this.game.moves.length; if (movePlus.index > movesCount) { // This can only happen if I'm an observer and missed a move. - if (!this.gameIsLoading) { - this.gameIsLoading = true; - if (!this.gameRef.rid) - // This is my game: just reload. - this.loadGame(); - else { - // Just ask fullgame again (once!), this is much simpler. - // If this fails, the user could just reload page :/ - let self = this; - (function askIfPeerConnected() { - if (!!self.people[self.gameRef.rid]) - self.send("askfullgame", { target: self.gameRef.rid }); - else setTimeout(askIfPeerConnected, 1000); - })(); - } - } - } else { + this.gotMoveIdx = movePlus.index; + if (!this.gameIsLoading) this.askGameAgain(); + } + else { if ( movePlus.index < movesCount || this.gotMoveIdx >= movePlus.index @@ -672,7 +675,12 @@ export default { // Did lastate arrive before game was rendered? if (this.lastate) this.processLastate(); }); - this.gameIsLoading = false; + if (this.gameIsLoading) { + this.gameIsLoading = false; + if (this.gotMoveIdx >= game.moves.length) + // Some moves arrived meanwhile... + this.askGameAgain(); + } if (!!callback) callback(); }; if (!!game) {