X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=23c45783716158bcf543486bae8b862229d4e4a7;hp=2da8d9e016f76f4753f93365f946872e25d0b54b;hb=db1f1f9adb920605c7a16b060a7737e54636ee08;hpb=e891730f77312340d68bb7ef72a4207541fa3914 diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 2da8d9e0..23c45783 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -24,6 +24,7 @@ main :pastChats="game.chats" :newChat="newChat" @mychat="processChat" + @chatcleared="clearChat" ) .row #aboveBoard.col-sm-12.col-md-9.col-md-offset-3.col-lg-10.col-lg-offset-2 @@ -193,6 +194,29 @@ export default { Object.values(this.people).some(p => p.id == player.uid) ); }, + resetChatColor: function() { + // TODO: this is called twice, once on opening an once on closing + document.getElementById("chatBtn").classList.remove("somethingnew"); + }, + processChat: function(chat) { + this.send("newchat", { data: chat }); + // NOTE: anonymous chats in corr games are not stored on server (TODO?) + if (this.game.type == "corr" && this.st.user.id > 0) + GameStorage.update(this.gameRef.id, { chat: chat }); + }, + clearChat: function() { + // Nothing more to do if game is live (chats not recorded) + if (this.game.mycolor && this.game.type == "corr") { + ajax( + "/chats", + "DELETE", + {gid: this.game.id}, + () => { + this.$set(this.game, "pastChats", []); + } + ); + } + }, socketMessageListener: function(msg) { if (!this.conn) return; const data = JSON.parse(msg.data); @@ -634,7 +658,10 @@ export default { const sendMove = { move: filtered_move, addTime: addTime, - cancelDrawOffer: this.drawOffer == "" + cancelDrawOffer: this.drawOffer == "", + // Players' SID required for /mygames page + // TODO: precompute and add this field to game object? + players: this.game.players.map(p => p.sid) }; this.send("newmove", { data: sendMove }); } @@ -717,16 +744,6 @@ export default { } else doProcessMove(); }, - resetChatColor: function() { - // TODO: this is called twice, once on opening an once on closing - document.getElementById("chatBtn").classList.remove("somethingnew"); - }, - processChat: function(chat) { - this.send("newchat", { data: chat }); - // NOTE: anonymous chats in corr games are not stored on server (TODO?) - if (this.game.type == "corr" && this.st.user.id > 0) - GameStorage.update(this.gameRef.id, { chat: chat }); - }, gameOver: function(score, scoreMsg) { this.game.score = score; this.$set(this.game, "scoreMsg", scoreMsg || getScoreMessage(score));