From 23cc2b9d219ad2adf110aea2235c60ca03e4bc76 Mon Sep 17 00:00:00 2001 From: Bonnie L <11881979+bonnieetc@users.noreply.github.com> Date: Fri, 22 Mar 2019 05:54:10 +0800 Subject: [PATCH] catch promise rejection when user submits a message to group. fixes #10970 (#10978) * catch promise rejection when user submits a message to group * switch response exception handling to try/catch to avoid mixing aysnc/await with promises --- website/client/components/groups/chat.vue | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/website/client/components/groups/chat.vue b/website/client/components/groups/chat.vue index a2df8abd3ef..af7b065894c 100644 --- a/website/client/components/groups/chat.vue +++ b/website/client/components/groups/chat.vue @@ -124,12 +124,22 @@ 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 = ''; + let response; + + try { + response = await this.$store.dispatch('chat:postChat', { + group: this.group, + message: this.newMessage, + }); + } catch (e) { + // catch exception to allow function to continue + } + + if (response) { + this.group.chat.unshift(response.message); + this.newMessage = ''; + } + this.sending = false; // @TODO: I would like to not reload everytime we send. Why are we reloading?