Skip to content

Commit f72269c

Browse files
committed
fix: use getAttachmentIndex instead
1 parent 0d8b005 commit f72269c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/messageComposer/attachmentManager.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,12 @@ export class AttachmentManager {
448448
},
449449
};
450450

451-
this.upsertAttachments([failedAttachment]);
451+
const isAttachmentPresent = this.getAttachmentIndex(
452+
failedAttachment.localMetadata.id,
453+
);
454+
if (isAttachmentPresent !== -1) {
455+
this.upsertAttachments([failedAttachment]);
456+
}
452457
return failedAttachment;
453458
}
454459

@@ -482,11 +487,11 @@ export class AttachmentManager {
482487
(uploadedAttachment as LocalNotImageAttachment).thumb_url = response.thumb_url;
483488
}
484489

485-
if (
486-
this.attachments.some(
487-
(att) => att.localMetadata.id === uploadedAttachment.localMetadata.id,
488-
)
489-
) {
490+
const isAttachmentPresent = this.getAttachmentIndex(
491+
uploadedAttachment.localMetadata.id,
492+
);
493+
494+
if (isAttachmentPresent !== -1) {
490495
this.upsertAttachments([uploadedAttachment]);
491496
}
492497

0 commit comments

Comments
 (0)