X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FChat.vue;h=a31f8d0b185448aa7c1cd5c96c330dae98ef665d;hb=616561273f216debfeab7f5fc532d0b0a8bc8e2d;hp=6eb7ef31bcb7442b3326d89fd63125ec9aa46c4b;hpb=3b959cfaf3d3a28373d7ebb48d80087150a98006;p=vchess.git diff --git a/client/src/components/Chat.vue b/client/src/components/Chat.vue index 6eb7ef31..a31f8d0b 100644 --- a/client/src/components/Chat.vue +++ b/client/src/components/Chat.vue @@ -21,19 +21,13 @@ import { store } from "@/store"; export default { name: "my-chat", // Prop 'pastChats' for corr games where chats are on server - props: ["players", "pastChats", "newChat"], + props: ["players", "pastChats"], data: function() { return { st: store.state, chats: [] //chat messages after human game }; }, - watch: { - newChat: function(chat) { - if (chat.msg != "") - this.chats.unshift({ msg: chat.msg, name: chat.name || "@nonymous" }); - } - }, methods: { classObject: function(chat) { return { @@ -48,12 +42,17 @@ export default { sendChat: function() { let chatInput = document.getElementById("inputChat"); const chatTxt = chatInput.value.trim(); + chatInput.focus(); //required on smartphones if (chatTxt == "") return; //nothing to send chatInput.value = ""; const chat = { msg: chatTxt, name: this.st.user.name || "@nonymous" }; this.$emit("mychat", chat); this.chats.unshift(chat); }, + newChat: function(chat) { + if (chat.msg != "") + this.chats.unshift({ msg: chat.msg, name: chat.name || "@nonymous" }); + }, clearHistory: function() { this.chats = []; this.$emit("chatcleared");