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
This commit is contained in:
Bonnie L 2019-03-22 05:54:10 +08:00 committed by Sabe Jones
parent 58c4fcd506
commit 23cc2b9d21

View file

@ -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?