From 42a4bbeab7830ac78619dc4d8fb31bdf0959a536 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/website/client/components/groups/chat.vue b/website/client/components/groups/chat.vue index ce121d58b2..e1da7571fa 100644 --- a/website/client/components/groups/chat.vue +++ b/website/client/components/groups/chat.vue @@ -123,15 +123,19 @@ } }, 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; this.$refs['user-entry'].innerText = ''; - // @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; }, @@ -153,6 +157,10 @@ }, 500); }, + selectedAutocomplete (newText) { + this.newMessage = newText; + }, + fetchRecentMessages () { this.$emit('fetchRecentMessages'); }, @@ -235,6 +243,7 @@ box-shadow: 0 0 3pt 2pt white; border-radius: 2px; line-height: 1.43; + color: $gray-300; padding: .5em; -moz-appearance: textfield-multiline; -webkit-appearance: textarea;