@@ -295,7 +295,7 @@ class NewMessageViewModel @Inject constructor(
295
295
if (remoteBody.isEmpty()) return
296
296
297
297
val (body, signature, quote) = when (draft.mimeType) {
298
- Utils .TEXT_PLAIN -> Triple (BodyContentPayload (remoteBody, BodyContentType .TEXT_PLAIN_WITHOUT_HTML ), null , null )
298
+ Utils .TEXT_PLAIN -> BodyData (BodyContentPayload (remoteBody, BodyContentType .TEXT_PLAIN_WITHOUT_HTML ), null , null )
299
299
Utils .TEXT_HTML -> splitSignatureAndQuoteFromHtml(remoteBody)
300
300
else -> error(" Cannot load an email which is not of type text/plain or text/html" )
301
301
}
@@ -307,7 +307,7 @@ class NewMessageViewModel @Inject constructor(
307
307
}
308
308
}
309
309
310
- private fun splitSignatureAndQuoteFromHtml (draftBody : String ): Triple < BodyContentPayload , String ?, String ?> {
310
+ private fun splitSignatureAndQuoteFromHtml (draftBody : String ): BodyData {
311
311
312
312
fun Document.split (divClassName : String , defaultValue : String ): Pair <String , String ?> {
313
313
return getElementsByClass(divClassName).firstOrNull()?.let {
@@ -335,7 +335,7 @@ class NewMessageViewModel @Inject constructor(
335
335
doc.split(MessageBodyUtils .INFOMANIAK_FORWARD_QUOTE_HTML_CLASS_NAME , bodyWithQuote)
336
336
}
337
337
338
- return Triple (BodyContentPayload (body, BodyContentType .HTML_UNSANITIZED ), signature, quote)
338
+ return BodyData (BodyContentPayload (body, BodyContentType .HTML_UNSANITIZED ), signature, quote)
339
339
}
340
340
341
341
private fun populateWithExternalMailDataIfNeeded (draft : Draft , intent : Intent ) {
@@ -774,7 +774,7 @@ class NewMessageViewModel @Inject constructor(
774
774
}.onFailure(Sentry ::captureException)
775
775
}
776
776
777
- fun saveBodyAndSubject (subject : String , html : String ) {
777
+ fun storeBodyAndSubject (subject : String , html : String ) {
778
778
globalCoroutineScope.launch(ioDispatcher) {
779
779
_subjectAndBodyChannel .send(SubjectAndBodyData (subject, html, channelExpirationIdTarget))
780
780
}
@@ -863,7 +863,7 @@ class NewMessageViewModel @Inject constructor(
863
863
864
864
val signature = uiSignatureLiveData.value
865
865
val quote = uiQuoteLiveData.value
866
- body = assembleWholeBody( uiBodyValue, signature, quote)
866
+ body = uiBodyValue + ( signature ? : " " ) + ( quote ? : " " )
867
867
868
868
/* *
869
869
* If we are opening for the 1st time an existing Draft created somewhere else
@@ -927,9 +927,6 @@ class NewMessageViewModel @Inject constructor(
927
927
SentryDebug .addAttachmentsBreadcrumb(draft = this , step)
928
928
}
929
929
930
- private fun assembleWholeBody (body : String , signature : String? , quote : String? ): String =
931
- body + (signature ? : " " ) + (quote ? : " " )
932
-
933
930
private fun isSnapshotTheSame (subjectValue : String? , uiBodyValue : String ): Boolean {
934
931
return snapshot?.let { draftSnapshot ->
935
932
draftSnapshot.identityId == fromLiveData.value?.signature?.id?.toString() &&
@@ -1024,6 +1021,8 @@ class NewMessageViewModel @Inject constructor(
1024
1021
1025
1022
private data class SubjectAndBodyData (val subject : String , val body : String , val expirationId : Int )
1026
1023
1024
+ private data class BodyData (val body : BodyContentPayload , val signature : String? , val quote : String? )
1025
+
1027
1026
companion object {
1028
1027
private val TAG = NewMessageViewModel ::class .java.simpleName
1029
1028
private const val ATTACHMENTS_MAX_SIZE = 25L * 1_024L * 1_024L // 25 MB
0 commit comments