Skip to content

Commit

Permalink
fix: Realm doesn't fail silently anymore when trying to update upload…
Browse files Browse the repository at this point in the history
…ed Attachments
  • Loading branch information
KevinBoulongne committed Mar 7, 2025
1 parent f48fa20 commit 3f6ee11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/src/main/java/com/infomaniak/mail/utils/DraftUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ private suspend fun Draft.uploadAttachments(mailbox: Mailbox, draftController: D
it.attachmentUploadStatus == AttachmentUploadStatus.AWAITING
}

suspend fun setUploadStatus(attachment: Attachment, uploadStatus: AttachmentUploadStatus, step: String) {
realm.write {
fun setUploadStatus(attachment: Attachment, uploadStatus: AttachmentUploadStatus, step: String) {
// This `writeBlocking` is on purpose. A simple `write` here will fail silently.
realm.writeBlocking {
draftController.updateDraft(localUuid, realm = this) {
it.attachments.findSpecificAttachment(attachment)?.setUploadStatus(uploadStatus, draft = it, step)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ object AttachmentExtensions {
}
}

private suspend fun Attachment.updateLocalAttachment(
private fun Attachment.updateLocalAttachment(
draftLocalUuid: String,
remoteAttachment: Attachment,
draftController: DraftController,
realm: Realm,
) {
realm.write {
// This `writeBlocking` is on purpose. A simple `write` here will fail silently.
realm.writeBlocking {
draftController.updateDraft(draftLocalUuid, realm = this) { draft ->

val uuidToLocalUri = draft.attachments.map { it.uuid to it.uploadLocalUri }
Expand Down

0 comments on commit 3f6ee11

Please sign in to comment.