From 067e8691416fb9a81e8ff5a8704da135dceb8f82 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Sun, 18 Nov 2018 19:38:56 +0100 Subject: [PATCH] fix(chat): prevent duplicate messages, closes #10823 --- website/client/components/groups/chat.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/website/client/components/groups/chat.vue b/website/client/components/groups/chat.vue index 0f6b23164c..8575f42c96 100644 --- a/website/client/components/groups/chat.vue +++ b/website/client/components/groups/chat.vue @@ -57,6 +57,7 @@ data () { return { newMessage: '', + sending: false, caretPosition: 0, chat: { submitDisable: false, @@ -111,14 +112,18 @@ } }, async sendMessage () { + if (this.sending) return; + this.sending = true; let response = await this.$store.dispatch('chat:postChat', { group: this.group, message: this.newMessage, }); this.group.chat.unshift(response.message); this.newMessage = ''; + this.sending = false; - // @TODO: I would like to not reload everytime we send. Realtime/Firebase? + // @TODO: I would like to not reload everytime we send. Why are we reloading? + // The response has all the necessary data... let chat = await this.$store.dispatch('chat:getChat', {groupId: this.group._id}); this.group.chat = chat; },