From c0cd747f29e8acf4a0fbe6a69589af5a877abb86 Mon Sep 17 00:00:00 2001 From: Sabin Date: Thu, 2 Jul 2020 12:13:02 +0545 Subject: [PATCH] Bug: Fix duplicate messages while using `enter` key on slow network (#987) Co-authored-by: Pranav Raj S --- .../dashboard/components/widgets/conversation/ReplyBox.vue | 5 +++-- db/seeds.rb | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue index c74854ff3..b11b22057 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue @@ -212,18 +212,19 @@ export default { if (this.message.length > this.maxLength) { return; } + const newMessage = this.message; if (!this.showCannedResponsesList) { + this.clearMessage(); try { await this.$store.dispatch('sendMessage', { conversationId: this.currentChat.id, - message: this.message, + message: newMessage, private: this.isPrivate, }); this.$emit('scrollToMessage'); } catch (error) { // Error } - this.clearMessage(); this.hideEmojiPicker(); } }, diff --git a/db/seeds.rb b/db/seeds.rb index 62eddc327..b56da8239 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -35,3 +35,4 @@ conversation = Conversation.create!( additional_attributes: {} ) Message.create!(content: 'Hello', account: account, inbox: inbox, conversation: conversation, message_type: :incoming) +CannedResponse.create!(account: account, short_code: 'start', content: 'Hello welcome to chatwoot.')