Skip to content

Commit

Permalink
Don't replace Attachments with the 1st one when forwarding a Message
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Jun 18, 2024
1 parent 155e091 commit 09fae56
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,13 @@ class NewMessageViewModel @Inject constructor(

private fun Draft.updateDraftAttachmentsFromLiveData() {
val updatedAttachments = attachmentsLiveData.valueOrEmpty().map { uiAttachment ->
// If a localAttachment has the same `uploadLocalUri` than a UI one, it means it represents the same Attachment.
val localAttachment = attachments.filter { it.uploadLocalUri == uiAttachment.uploadLocalUri }
val localAttachment = attachments
/**
* If a localAttachment has the same `uploadLocalUri` than a UI one, it means it represents the same Attachment.
* But an Attachment only has an `uploadLocalUri` if the user added it to the Draft.
* If it was added by forwarding a Message, it's doesn't have a `uploadLocalUri`, so we don't check this.
*/
.filter { it.uploadLocalUri != null && it.uploadLocalUri == uiAttachment.uploadLocalUri }
.also {
// If this Sentry never triggers, remove it and replace the
// `attachments.filter { … }.also { … }.firstOrNull()` with `attachments.singleOrNull { … }`
Expand Down

0 comments on commit 09fae56

Please sign in to comment.