From a4480041556612060da8ba4cf30adc48895d746e Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sat, 7 Dec 2019 01:41:43 +0100
Subject: [PATCH] Debug newmove + messages

---
 client/src/components/BaseGame.vue |  3 +++
 client/src/views/Game.vue          | 20 +++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

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
-- 
2.44.0