mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 10:19:08 +00:00
ConversationView.hasFiles: Exclude pending attachments by default
This commit is contained in:
@@ -2009,11 +2009,15 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
hasFiles(): boolean {
|
hasFiles(options: { includePending: boolean }): boolean {
|
||||||
const draftAttachments = this.model.get('draftAttachments') || [];
|
const draftAttachments = this.model.get('draftAttachments') || [];
|
||||||
|
if (options.includePending) {
|
||||||
return draftAttachments.length > 0;
|
return draftAttachments.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return draftAttachments.some(item => !item.pending);
|
||||||
|
}
|
||||||
|
|
||||||
async getFiles(): Promise<Array<AttachmentType>> {
|
async getFiles(): Promise<Array<AttachmentType>> {
|
||||||
if (this.voiceNoteAttachment) {
|
if (this.voiceNoteAttachment) {
|
||||||
// We don't need to pull these off disk; we return them as-is
|
// We don't need to pull these off disk; we return them as-is
|
||||||
@@ -2092,7 +2096,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
this.toggleMicrophone();
|
this.toggleMicrophone();
|
||||||
if (this.hasFiles()) {
|
if (this.hasFiles({ includePending: true })) {
|
||||||
this.removeLinkPreview();
|
this.removeLinkPreview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2333,7 +2337,9 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleMicrophone(): void {
|
toggleMicrophone(): void {
|
||||||
this.compositionApi.current?.setShowMic(!this.hasFiles());
|
this.compositionApi.current?.setShowMic(
|
||||||
|
!this.hasFiles({ includePending: true })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
captureAudio(e?: Event): void {
|
captureAudio(e?: Event): void {
|
||||||
@@ -2345,7 +2351,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasFiles()) {
|
if (this.hasFiles({ includePending: true })) {
|
||||||
this.showToast(Whisper.VoiceNoteMustBeOnlyAttachmentToast);
|
this.showToast(Whisper.VoiceNoteMustBeOnlyAttachmentToast);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2388,7 +2394,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
async handleAudioCapture(blob: Blob): Promise<void> {
|
async handleAudioCapture(blob: Blob): Promise<void> {
|
||||||
if (this.hasFiles()) {
|
if (this.hasFiles({ includePending: true })) {
|
||||||
throw new Error('A voice note cannot be sent with other attachments');
|
throw new Error('A voice note cannot be sent with other attachments');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4162,7 +4168,11 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!message.length && !this.hasFiles() && !this.voiceNoteAttachment) {
|
if (
|
||||||
|
!message.length &&
|
||||||
|
!this.hasFiles({ includePending: false }) &&
|
||||||
|
!this.voiceNoteAttachment
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4255,7 +4265,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If we have attachments, don't add link preview
|
// If we have attachments, don't add link preview
|
||||||
if (this.hasFiles()) {
|
if (this.hasFiles({ includePending: true })) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If we're behind a user-configured proxy, we don't support link previews
|
// If we're behind a user-configured proxy, we don't support link previews
|
||||||
|
|||||||
Reference in New Issue
Block a user