DEV: Use await when sending chat messages (#21915)
This is a follow-up to d086888
, I forgot to update these places in that commit.
This commit is contained in:
parent
8c4cbd748d
commit
b7a66bd6ad
|
@ -724,28 +724,24 @@ export default class ChatLivePane extends Component {
|
|||
this.scrollToLatestMessage();
|
||||
}
|
||||
|
||||
return this.chatApi
|
||||
.sendMessage(this.args.channel.id, {
|
||||
try {
|
||||
await this.chatApi.sendMessage(this.args.channel.id, {
|
||||
message: message.message,
|
||||
in_reply_to_id: message.inReplyTo?.id,
|
||||
staged_id: message.id,
|
||||
upload_ids: message.uploads.map((upload) => upload.id),
|
||||
})
|
||||
.then(() => {
|
||||
this.scrollToLatestMessage();
|
||||
})
|
||||
.catch((error) => {
|
||||
this._onSendError(message.id, error);
|
||||
this.scrollToBottom();
|
||||
})
|
||||
.finally(() => {
|
||||
if (this._selfDeleted) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
this.scrollToLatestMessage();
|
||||
} catch (error) {
|
||||
this._onSendError(message.id, error);
|
||||
this.scrollToBottom();
|
||||
} finally {
|
||||
if (!this._selfDeleted) {
|
||||
this.chatDraftsManager.remove({ channelId: this.args.channel.id });
|
||||
this.chatChannelPane.sending = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _upsertChannelWithMessage(channel, data) {
|
||||
|
|
|
@ -250,8 +250,8 @@ export default class ChatThreadPanel extends Component {
|
|||
|
||||
this.scrollToBottom();
|
||||
|
||||
return this.chatApi
|
||||
.sendMessage(this.channel.id, {
|
||||
try {
|
||||
await this.chatApi.sendMessage(this.channel.id, {
|
||||
message: message.message,
|
||||
in_reply_to_id: message.thread.staged
|
||||
? message.thread.originalMessage.id
|
||||
|
@ -260,16 +260,14 @@ export default class ChatThreadPanel extends Component {
|
|||
upload_ids: message.uploads.map((upload) => upload.id),
|
||||
thread_id: message.thread.staged ? null : message.thread.id,
|
||||
staged_thread_id: message.thread.staged ? message.thread.id : null,
|
||||
})
|
||||
.catch((error) => {
|
||||
this.#onSendError(message.id, error);
|
||||
})
|
||||
.finally(() => {
|
||||
if (this._selfDeleted) {
|
||||
return;
|
||||
}
|
||||
this.chatChannelThreadPane.sending = false;
|
||||
});
|
||||
} catch (error) {
|
||||
this.#onSendError(message.id, error);
|
||||
} finally {
|
||||
if (!this._selfDeleted) {
|
||||
this.chatChannelThreadPane.sending = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async #sendEditMessage(message) {
|
||||
|
|
Loading…
Reference in New Issue