Skip to content

Commit

Permalink
catch promise rejection when user submits a message to group. fixes #…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Bonnie L authored and SabreCat committed Mar 21, 2019
1 parent 58c4fcd commit 23cc2b9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions website/client/components/groups/chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 23cc2b9

Please sign in to comment.