@@ -68,11 +68,16 @@ import com.infomaniak.mail.di.MainDispatcher
68
68
import com.infomaniak.mail.ui.main.SnackbarManager
69
69
import com.infomaniak.mail.ui.newMessage.NewMessageEditorManager.EditorAction
70
70
import com.infomaniak.mail.ui.newMessage.NewMessageRecipientFieldsManager.FieldType
71
- import com.infomaniak.mail.ui.newMessage.NewMessageViewModel.SignatureScore.*
71
+ import com.infomaniak.mail.ui.newMessage.NewMessageViewModel.SignatureScore.EXACT_MATCH
72
+ import com.infomaniak.mail.ui.newMessage.NewMessageViewModel.SignatureScore.EXACT_MATCH_AND_IS_DEFAULT
73
+ import com.infomaniak.mail.ui.newMessage.NewMessageViewModel.SignatureScore.NO_MATCH
74
+ import com.infomaniak.mail.ui.newMessage.NewMessageViewModel.SignatureScore.ONLY_EMAIL_MATCH
75
+ import com.infomaniak.mail.ui.newMessage.NewMessageViewModel.SignatureScore.ONLY_EMAIL_MATCH_AND_IS_DEFAULT
72
76
import com.infomaniak.mail.utils.AccountUtils
73
77
import com.infomaniak.mail.utils.ContactUtils.arrangeMergedContacts
74
78
import com.infomaniak.mail.utils.LocalStorageUtils
75
79
import com.infomaniak.mail.utils.MessageBodyUtils
80
+ import com.infomaniak.mail.utils.SentryDebug
76
81
import com.infomaniak.mail.utils.SharedUtils
77
82
import com.infomaniak.mail.utils.SignatureUtils
78
83
import com.infomaniak.mail.utils.Utils
@@ -93,14 +98,14 @@ import io.realm.kotlin.ext.realmListOf
93
98
import io.realm.kotlin.ext.toRealmList
94
99
import io.realm.kotlin.types.RealmList
95
100
import io.sentry.Sentry
101
+ import javax.inject.Inject
96
102
import kotlinx.coroutines.CoroutineDispatcher
97
103
import kotlinx.coroutines.CoroutineScope
98
104
import kotlinx.coroutines.flow.map
99
105
import kotlinx.coroutines.launch
100
106
import kotlinx.coroutines.withContext
101
107
import org.jsoup.Jsoup
102
108
import org.jsoup.nodes.Document
103
- import javax.inject.Inject
104
109
105
110
@HiltViewModel
106
111
class NewMessageViewModel @Inject constructor(
@@ -339,6 +344,8 @@ class NewMessageViewModel @Inject constructor(
339
344
}
340
345
341
346
if (mailToUri != null ) handleMailTo(draft, mailToUri)
347
+
348
+ SentryDebug .addAttachmentsBreadcrumb(draft, step = " populate Draft with external mail data" )
342
349
}
343
350
344
351
private fun Draft.flagRecipientsAsAutomaticallyEntered () {
@@ -747,7 +754,12 @@ class NewMessageViewModel @Inject constructor(
747
754
fun uploadAttachmentsToServer (uiAttachments : List <Attachment >) = viewModelScope.launch(ioDispatcher) {
748
755
val localUuid = draftLocalUuid ? : return @launch
749
756
val localDraft = mailboxContentRealm().writeBlocking {
750
- DraftController .getDraft(localUuid, realm = this )?.also { it.updateDraftAttachmentsWithLiveData(uiAttachments) }
757
+ DraftController .getDraft(localUuid, realm = this )?.also {
758
+ it.updateDraftAttachmentsWithLiveData(
759
+ uiAttachments = uiAttachments,
760
+ step = " observeAttachments -> uploadAttachmentsToServer" ,
761
+ )
762
+ }
751
763
} ? : return @launch
752
764
753
765
runCatching {
@@ -813,7 +825,10 @@ class NewMessageViewModel @Inject constructor(
813
825
cc = ccLiveData.valueOrEmpty().toRealmList()
814
826
bcc = bccLiveData.valueOrEmpty().toRealmList()
815
827
816
- updateDraftAttachmentsWithLiveData(attachmentsLiveData.valueOrEmpty())
828
+ updateDraftAttachmentsWithLiveData(
829
+ uiAttachments = attachmentsLiveData.valueOrEmpty(),
830
+ step = " executeDraftActionWhenStopping (action = ${draftAction.name} ) -> updateDraftFromLiveData" ,
831
+ )
817
832
818
833
subject = subjectValue
819
834
@@ -848,7 +863,7 @@ class NewMessageViewModel @Inject constructor(
848
863
}
849
864
}
850
865
851
- private fun Draft.updateDraftAttachmentsWithLiveData (uiAttachments : List <Attachment >) {
866
+ private fun Draft.updateDraftAttachmentsWithLiveData (uiAttachments : List <Attachment >, step : String ) {
852
867
853
868
/* *
854
869
* If :
@@ -882,6 +897,8 @@ class NewMessageViewModel @Inject constructor(
882
897
clear()
883
898
addAll(updatedAttachments)
884
899
}
900
+
901
+ SentryDebug .addAttachmentsBreadcrumb(draft = this , step)
885
902
}
886
903
887
904
private fun Draft.getWholeBody (): String = uiBody.textToHtml() + (uiSignature ? : " " ) + (uiQuote ? : " " )
0 commit comments