Fixes
[vchess.git] / client / src / components / Chat.vue
index 980cd17..8f1646f 100644 (file)
@@ -3,7 +3,8 @@
   input#inputChat(type="text" :placeholder="st.tr['Type here']"
     @keyup.enter="sendChat")
   button#sendChatBtn(@click="sendChat") {{ st.tr["Send"] }}
-  p(v-for="chat in chats" :class="classObject(chat)" v-html="chat.msg")
+  p(v-for="chat in pastChats" :class="classObject(chat)" v-html="chat.name + ': ' + chat.msg")
+  p(v-for="chat in chats" :class="classObject(chat)" v-html="chat.name + ': ' + chat.msg")
 </template>
 
 <script>
@@ -11,7 +12,8 @@ import { store } from "@/store";
 
 export default {
   name: "my-chat",
-  props: ["players"],
+  // Prop 'pastChats' for corr games where chats are on server
+  props: ["players","pastChats"],
   data: function() {
     return {
       st: store.state,
@@ -51,6 +53,7 @@ export default {
       chatInput.value = "";
       const chat = {msg:chatTxt, name: this.st.user.name || "@nonymous",
         sid:this.st.user.sid};
+      this.$emit("newchat", chat); //useful for corr games
       this.chats.unshift(chat);
       this.st.conn.send(JSON.stringify({
         code:"newchat", msg:chatTxt, name:chat.name}));