Debug newmove + messages
authorBenjamin Auder <benjamin.auder@somewhere>
Sat, 7 Dec 2019 00:41:43 +0000 (01:41 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sat, 7 Dec 2019 00:41:43 +0000 (01:41 +0100)
client/src/components/BaseGame.vue
client/src/views/Game.vue

index 100eadf..83311cc 100644 (file)
@@ -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
index 2d5838d..4d44cd1 100644 (file)
@@ -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