Skip to content

Commit 8084b10

Browse files
refactor: Rename AttachmentUpload statuses
1 parent cc327c0 commit 8084b10

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

app/src/main/java/com/infomaniak/mail/data/models/Attachment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Attachment : EmbeddedRealmObject, Attachable {
5858
@Transient
5959
var uploadLocalUri: String? = null
6060
@Transient
61-
private var _uploadStatus: String = AttachmentUploadStatus.AWAITING.name
61+
private var _uploadStatus: String = AttachmentUploadStatus.NOT_UPLOADED.name
6262
//endregion
6363

6464
val attachmentUploadStatus: AttachmentUploadStatus?
@@ -85,7 +85,7 @@ class Attachment : EmbeddedRealmObject, Attachable {
8585
fun backupLocalData(oldAttachment: Attachment, draft: Draft) {
8686
localUuid = oldAttachment.localUuid
8787
uploadLocalUri = oldAttachment.uploadLocalUri
88-
setUploadStatus(AttachmentUploadStatus.FINISHED, draft, "backupLocalData -> setUploadStatus")
88+
setUploadStatus(AttachmentUploadStatus.UPLOADED, draft, "backupLocalData -> setUploadStatus")
8989
}
9090

9191
fun setUploadStatus(attachmentUploadStatus: AttachmentUploadStatus, draft: Draft? = null, step: String = "") {

app/src/main/java/com/infomaniak/mail/data/models/AttachmentUploadStatus.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
package com.infomaniak.mail.data.models
1919

2020
enum class AttachmentUploadStatus {
21-
AWAITING,
22-
FINISHED,
21+
NOT_UPLOADED,
22+
UPLOADED,
2323
}

app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageViewModel.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class NewMessageViewModel @Inject constructor(
323323
ApiRepository.attachmentsToForward(mailboxUuid, previousMessage).data?.attachments?.forEach { attachment ->
324324
draft.attachments += attachment.apply {
325325
resource = previousMessage.attachments.find { it.name == name }?.resource
326-
setUploadStatus(AttachmentUploadStatus.FINISHED)
326+
setUploadStatus(AttachmentUploadStatus.UPLOADED)
327327
}
328328
SentryDebug.addDraftBreadcrumbs(draft, step = "set previousMessage when reply/replyAll/Forward")
329329
}
@@ -507,11 +507,11 @@ class NewMessageViewModel @Inject constructor(
507507
return ApiRepository.getDraft(draftResource!!).data?.also { draft ->
508508

509509
/**
510-
* If we are opening for the 1st time an existing Draft created somewhere else (ex: webmail),
511-
* we need to set all of its Attachments to `FINISHED`, so we don't try to upload them again.
510+
* If we are opening for the 1st time an existing Draft created somewhere else (ex: webmail), we need to
511+
* set all of its Attachments to [AttachmentUploadStatus.UPLOADED], so we don't try to upload them again.
512512
*/
513513
draft.attachments.forEach {
514-
it.setUploadStatus(AttachmentUploadStatus.FINISHED, draft, "fetchDraft at NewMessage opening")
514+
it.setUploadStatus(AttachmentUploadStatus.UPLOADED, draft, "fetchDraft at NewMessage opening")
515515
}
516516

517517
/**
@@ -989,7 +989,7 @@ class NewMessageViewModel @Inject constructor(
989989
* Then it means the Attachments list hasn't been edited by the user, so we have nothing to do here.
990990
*/
991991
val isForwardingUneditedAttachmentsList = draftMode == DraftMode.FORWARD &&
992-
uiAttachments.all { it.attachmentUploadStatus == AttachmentUploadStatus.FINISHED } &&
992+
uiAttachments.all { it.attachmentUploadStatus == AttachmentUploadStatus.UPLOADED } &&
993993
uiAttachments.count() == attachments.count()
994994
if (isForwardingUneditedAttachmentsList) return
995995

@@ -1002,7 +1002,7 @@ class NewMessageViewModel @Inject constructor(
10021002
* be some data for Attachments in Realm (for example, the `uuid`). If we don't take back the Realm version of the
10031003
* Attachment, this data will be lost forever and we won't be able to save/send the Draft.
10041004
*/
1005-
return@map if (localAttachment != null && localAttachment.attachmentUploadStatus != AttachmentUploadStatus.AWAITING) {
1005+
return@map if (localAttachment != null && localAttachment.attachmentUploadStatus == AttachmentUploadStatus.UPLOADED) {
10061006
localAttachment.copyFromRealm()
10071007
} else {
10081008
uiAttachment

app/src/main/java/com/infomaniak/mail/utils/DraftUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ suspend fun uploadAttachmentsWithMutex(
4949
private suspend fun Draft.uploadAttachments(mailbox: Mailbox, draftController: DraftController, realm: Realm) {
5050

5151
fun getAwaitingAttachments(): List<Attachment> = attachments.filter {
52-
it.attachmentUploadStatus == AttachmentUploadStatus.AWAITING
52+
it.attachmentUploadStatus == AttachmentUploadStatus.NOT_UPLOADED
5353
}
5454

5555
suspend fun setUploadStatus(attachment: Attachment, uploadStatus: AttachmentUploadStatus, step: String) {

app/src/main/java/com/infomaniak/mail/workers/DraftsActionsWorker.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class DraftsActionsWorker @AssistedInject constructor(
325325
SentryDebug.addDraftBreadcrumbs(draft, step = "executeDraftAction (action = ${draft.action?.name.toString()})")
326326

327327
// TODO: Remove this whole `draft.attachments.any { … }` + `addDraftBreadcrumbs()` when the Attachments issue is fixed.
328-
if (draft.attachments.any { it.attachmentUploadStatus != AttachmentUploadStatus.FINISHED }) {
328+
if (draft.attachments.any { it.attachmentUploadStatus != AttachmentUploadStatus.UPLOADED }) {
329329

330330
Sentry.captureMessage(
331331
"We tried to [${draft.action?.name}] a Draft, but an Attachment wasn't uploaded.",

0 commit comments

Comments
 (0)