diff --git a/ts/components/conversation/composition/CompositionBox.tsx b/ts/components/conversation/composition/CompositionBox.tsx index 466a9aeb00..98a45b35cf 100644 --- a/ts/components/conversation/composition/CompositionBox.tsx +++ b/ts/components/conversation/composition/CompositionBox.tsx @@ -276,6 +276,7 @@ class CompositionBoxInner extends React.Component { private linkPreviewAbortController?: AbortController; private container: HTMLDivElement | null; private lastBumpTypingMessageLength: number = 0; + private isSendingMessage: boolean; constructor(props: Props) { super(props); @@ -290,6 +291,8 @@ class CompositionBoxInner extends React.Component { this.emojiPanelButton = React.createRef(); autoBind(this); this.toggleEmojiPanel = debounce(this.toggleEmojiPanel.bind(this), 100); + + this.isSendingMessage = false; } public componentDidMount() { @@ -907,6 +910,10 @@ class CompositionBoxInner extends React.Component { if (!this.props.selectedConversationKey) { throw new Error('selectedConversationKey is needed'); } + if (this.isSendingMessage) { + return; + } + this.linkPreviewAbortController?.abort(); const messagePlaintext = cleanMentions(this.state.draft); @@ -956,6 +963,8 @@ class CompositionBoxInner extends React.Component { ? _.pick(stagedLinkPreview, 'url', 'image', 'title') : undefined; + this.isSendingMessage = true; + try { // this does not call call removeAllStagedAttachmentsInConvers const { attachments, previews } = await this.getFiles(linkPreview); @@ -986,6 +995,8 @@ class CompositionBoxInner extends React.Component { } catch (e) { // Message sending failed window?.log?.error(e); + } finally { + this.isSendingMessage = false; } }