<template lang="pug">
div
button(@click="clearHistory()")
- | {{ st.tr["Clear chat"] }}
+ | {{ st.tr["Clear history"] }}
input#inputChat(
type="text"
:placeholder="st.tr['Chat here']"
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 {
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");