@@ -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 ) {
@@ -767,7 +767,7 @@ class NewMessageViewModel @Inject constructor(
767
767
}.onFailure(Sentry ::captureException)
768
768
}
769
769
770
- fun saveBodyAndSubject (subject : String , html : String ) {
770
+ fun storeBodyAndSubject (subject : String , html : String ) {
771
771
globalCoroutineScope.launch(ioDispatcher) {
772
772
_subjectAndBodyChannel .send(SubjectAndBodyData (subject, html, channelExpirationIdTarget))
773
773
}
@@ -853,7 +853,7 @@ class NewMessageViewModel @Inject constructor(
853
853
854
854
val signature = uiSignatureLiveData.value
855
855
val quote = uiQuoteLiveData.value
856
- body = assembleWholeBody( uiBodyValue, signature, quote)
856
+ body = uiBodyValue + ( signature ? : " " ) + ( quote ? : " " )
857
857
858
858
/* *
859
859
* If we are opening for the 1st time an existing Draft created somewhere else
@@ -915,9 +915,6 @@ class NewMessageViewModel @Inject constructor(
915
915
}
916
916
}
917
917
918
- private fun assembleWholeBody (body : String , signature : String? , quote : String? ): String =
919
- body + (signature ? : " " ) + (quote ? : " " )
920
-
921
918
private fun isSnapshotTheSame (subjectValue : String? , uiBodyValue : String ): Boolean {
922
919
return snapshot?.let { draftSnapshot ->
923
920
draftSnapshot.identityId == fromLiveData.value?.signature?.id?.toString() &&
@@ -1012,6 +1009,8 @@ class NewMessageViewModel @Inject constructor(
1012
1009
1013
1010
private data class SubjectAndBodyData (val subject : String , val body : String , val expirationId : Int )
1014
1011
1012
+ private data class BodyData (val body : BodyContentPayload , val signature : String? , val quote : String? )
1013
+
1015
1014
companion object {
1016
1015
private val TAG = NewMessageViewModel ::class .java.simpleName
1017
1016
private const val ATTACHMENTS_MAX_SIZE = 25L * 1_024L * 1_024L // 25 MB
0 commit comments