From: Benjamin Auder Date: Sat, 7 Dec 2019 00:41:43 +0000 (+0100) Subject: Debug newmove + messages X-Git-Url: https://git.auder.net/doc/html/%7B%7B%20asset%28%27mixstore/css/static/policy.css%27%29%20%7D%7D?a=commitdiff_plain;h=a4480041556612060da8ba4cf30adc48895d746e;p=vchess.git Debug newmove + messages --- diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index 100eadf0..83311cc1 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -105,6 +105,9 @@ export default { return ""; return this.game.moves[this.cursor].message || ""; }, + setCurrentMessage: function(message) { + this.game.moves[this.game.moves.length-1].message = message; + }, download: function() { const content = this.getPgn(); // Prepare and trigger download link diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 2d5838d4..4d44cd1a 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -451,11 +451,21 @@ export default { let sendMove = Object.assign({}, filtered_move, {addTime: addTime}); if (this.game.type == "corr") sendMove.message = this.corrMsg; - this.st.conn.send(JSON.stringify({ - code: "newmove", - target: this.getOppSid(), - move: sendMove, - })); + const oppsid = this.getOppSid(); + if (!!oppsid) + { + this.st.conn.send(JSON.stringify({ + code: "newmove", + target: oppsid, + move: sendMove, + })); + } + if (this.game.type == "corr" && this.corrMsg != "") + { + // Add message to last move in BaseGame: + // TODO: not very good style... + this.$refs["basegame"].setCurrentMessage(this.corrMsg); + } } else addTime = move.addTime; //supposed transmitted