diff --git a/ts/views/conversation_view.ts b/ts/views/conversation_view.ts index 1f8e4ce9b..690aeaf42 100644 --- a/ts/views/conversation_view.ts +++ b/ts/views/conversation_view.ts @@ -2009,9 +2009,13 @@ export class ConversationView extends window.Backbone.View { ]); } - hasFiles(): boolean { + hasFiles(options: { includePending: boolean }): boolean { const draftAttachments = this.model.get('draftAttachments') || []; - return draftAttachments.length > 0; + if (options.includePending) { + return draftAttachments.length > 0; + } + + return draftAttachments.some(item => !item.pending); } async getFiles(): Promise> { @@ -2092,7 +2096,7 @@ export class ConversationView extends window.Backbone.View { ) ); this.toggleMicrophone(); - if (this.hasFiles()) { + if (this.hasFiles({ includePending: true })) { this.removeLinkPreview(); } } @@ -2333,7 +2337,9 @@ export class ConversationView extends window.Backbone.View { } toggleMicrophone(): void { - this.compositionApi.current?.setShowMic(!this.hasFiles()); + this.compositionApi.current?.setShowMic( + !this.hasFiles({ includePending: true }) + ); } captureAudio(e?: Event): void { @@ -2345,7 +2351,7 @@ export class ConversationView extends window.Backbone.View { return; } - if (this.hasFiles()) { + if (this.hasFiles({ includePending: true })) { this.showToast(Whisper.VoiceNoteMustBeOnlyAttachmentToast); return; } @@ -2388,7 +2394,7 @@ export class ConversationView extends window.Backbone.View { }); } async handleAudioCapture(blob: Blob): Promise { - if (this.hasFiles()) { + if (this.hasFiles({ includePending: true })) { throw new Error('A voice note cannot be sent with other attachments'); } @@ -4162,7 +4168,11 @@ export class ConversationView extends window.Backbone.View { } try { - if (!message.length && !this.hasFiles() && !this.voiceNoteAttachment) { + if ( + !message.length && + !this.hasFiles({ includePending: false }) && + !this.voiceNoteAttachment + ) { return; } @@ -4255,7 +4265,7 @@ export class ConversationView extends window.Backbone.View { return; } // If we have attachments, don't add link preview - if (this.hasFiles()) { + if (this.hasFiles({ includePending: true })) { return; } // If we're behind a user-configured proxy, we don't support link previews