Fix display header message email quoted when forward email
This commit is contained in:
@@ -17,12 +17,14 @@ extension HtmlExtension on String {
|
|||||||
|
|
||||||
String addBlockTag(String tag, {String? attribute}) => attribute != null ? '<$tag $attribute>$this</$tag>' : '<$tag>$this</$tag>';
|
String addBlockTag(String tag, {String? attribute}) => attribute != null ? '<$tag $attribute>$this</$tag>' : '<$tag>$this</$tag>';
|
||||||
|
|
||||||
|
String append(String value) => this + value;
|
||||||
|
|
||||||
String addNewLineTag({int count = 1}) {
|
String addNewLineTag({int count = 1}) {
|
||||||
if (count == 1) return '$this<br>';
|
if (count == 1) return '$this</br>';
|
||||||
|
|
||||||
var htmlString = this;
|
var htmlString = this;
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
htmlString = '$htmlString<br>';
|
htmlString = '$htmlString</br>';
|
||||||
}
|
}
|
||||||
return htmlString;
|
return htmlString;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,11 +236,70 @@ class ComposerController extends BaseController {
|
|||||||
htmlControllerBrowser.setFullScreen();
|
htmlControllerBrowser.setFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
Tuple2<String, String>? _getHeaderEmailQuoted(String locale, ComposerArguments arguments) {
|
String? _getHeaderEmailQuoted(BuildContext context, ComposerArguments arguments) {
|
||||||
if (arguments.presentationEmail != null) {
|
final presentationEmail = arguments.presentationEmail;
|
||||||
final sentDate = arguments.presentationEmail?.sentAt;
|
if (presentationEmail != null) {
|
||||||
final emailAddress = arguments.presentationEmail?.from.listEmailAddressToString(isFullEmailAddress: true) ?? '';
|
final locale = Localizations.localeOf(context).toLanguageTag();
|
||||||
return Tuple2(sentDate.formatDate(pattern: 'MMM d, y h:mm a', locale: locale), emailAddress);
|
log('ComposerController::_getHeaderEmailQuoted(): emailActionType: ${arguments.emailActionType}');
|
||||||
|
switch(arguments.emailActionType) {
|
||||||
|
case EmailActionType.reply:
|
||||||
|
case EmailActionType.replyAll:
|
||||||
|
final sentDate = presentationEmail.sentAt;
|
||||||
|
final emailAddress = presentationEmail.from.listEmailAddressToString(isFullEmailAddress: true);
|
||||||
|
return AppLocalizations.of(context).header_email_quoted(
|
||||||
|
sentDate.formatDate(pattern: 'MMM d, y h:mm a', locale: locale),
|
||||||
|
emailAddress);
|
||||||
|
case EmailActionType.forward:
|
||||||
|
var headerQuoted = '------- ${AppLocalizations.of(context).forwarded_message} -------'.addNewLineTag();
|
||||||
|
|
||||||
|
final subject = presentationEmail.subject ?? '';
|
||||||
|
final sentDate = presentationEmail.sentAt;
|
||||||
|
final fromEmailAddress = presentationEmail.from.listEmailAddressToString(isFullEmailAddress: true);
|
||||||
|
final toEmailAddress = presentationEmail.to.listEmailAddressToString(isFullEmailAddress: true);
|
||||||
|
final ccEmailAddress = presentationEmail.cc.listEmailAddressToString(isFullEmailAddress: true);
|
||||||
|
final bccEmailAddress = presentationEmail.bcc.listEmailAddressToString(isFullEmailAddress: true);
|
||||||
|
|
||||||
|
if (subject.isNotEmpty) {
|
||||||
|
headerQuoted = headerQuoted
|
||||||
|
.append('${AppLocalizations.of(context).subject_email}: ')
|
||||||
|
.append(subject)
|
||||||
|
.addNewLineTag();
|
||||||
|
}
|
||||||
|
if (sentDate != null) {
|
||||||
|
headerQuoted = headerQuoted
|
||||||
|
.append('${AppLocalizations.of(context).date}: ')
|
||||||
|
.append(sentDate.formatDate(pattern: 'MMM d, y h:mm a', locale: locale))
|
||||||
|
.addNewLineTag();
|
||||||
|
}
|
||||||
|
if (fromEmailAddress.isNotEmpty) {
|
||||||
|
headerQuoted = headerQuoted
|
||||||
|
.append('${AppLocalizations.of(context).from_email_address_prefix}: ')
|
||||||
|
.append(fromEmailAddress)
|
||||||
|
.addNewLineTag();
|
||||||
|
}
|
||||||
|
if (toEmailAddress.isNotEmpty) {
|
||||||
|
headerQuoted = headerQuoted
|
||||||
|
.append('${AppLocalizations.of(context).to_email_address_prefix}: ')
|
||||||
|
.append(toEmailAddress)
|
||||||
|
.addNewLineTag();
|
||||||
|
}
|
||||||
|
if (ccEmailAddress.isNotEmpty) {
|
||||||
|
headerQuoted = headerQuoted
|
||||||
|
.append('${AppLocalizations.of(context).cc_email_address_prefix}: ')
|
||||||
|
.append(ccEmailAddress)
|
||||||
|
.addNewLineTag();
|
||||||
|
}
|
||||||
|
if (bccEmailAddress.isNotEmpty) {
|
||||||
|
headerQuoted = headerQuoted
|
||||||
|
.append('${AppLocalizations.of(context).bcc_email_address_prefix}: ')
|
||||||
|
.append(bccEmailAddress)
|
||||||
|
.addNewLineTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
return headerQuoted;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -312,11 +371,9 @@ class ComposerController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String getEmailContentQuotedAsHtml(BuildContext context, ComposerArguments arguments) {
|
String getEmailContentQuotedAsHtml(BuildContext context, ComposerArguments arguments) {
|
||||||
final headerEmailQuoted = _getHeaderEmailQuoted(Localizations.localeOf(context).toLanguageTag(), arguments);
|
final headerEmailQuoted = _getHeaderEmailQuoted(context, arguments);
|
||||||
|
log('ComposerController::getEmailContentQuotedAsHtml(): headerEmailQuoted: $headerEmailQuoted');
|
||||||
final headerEmailQuotedAsHtml = headerEmailQuoted != null
|
final headerEmailQuotedAsHtml = headerEmailQuoted != null ? headerEmailQuoted.addBlockTag('cite') : '';
|
||||||
? AppLocalizations.of(context).header_email_quoted(headerEmailQuoted.value1, headerEmailQuoted.value2).addBlockTag('cite')
|
|
||||||
: '';
|
|
||||||
|
|
||||||
final trustAsHtml = arguments.emailContents?.asHtmlString ?? '';
|
final trustAsHtml = arguments.emailContents?.asHtmlString ?? '';
|
||||||
final emailQuotedHtml = '<p></br></p>$headerEmailQuotedAsHtml${trustAsHtml.addBlockQuoteTag()}';
|
final emailQuotedHtml = '<p></br></p>$headerEmailQuotedAsHtml${trustAsHtml.addBlockQuoteTag()}';
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ class EmailController extends BaseController {
|
|||||||
emailActionType: emailActionType,
|
emailActionType: emailActionType,
|
||||||
presentationEmail: mailboxDashBoardController.selectedEmail.value!,
|
presentationEmail: mailboxDashBoardController.selectedEmail.value!,
|
||||||
emailContents: initialEmailContents,
|
emailContents: initialEmailContents,
|
||||||
attachments: attachments,
|
attachments: emailActionType == EmailActionType.forward ? attachments : null,
|
||||||
mailboxRole: mailboxDashBoardController.selectedMailbox.value?.role);
|
mailboxRole: mailboxDashBoardController.selectedMailbox.value?.role);
|
||||||
|
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
|
|||||||
@@ -522,12 +522,12 @@ class EmailView extends GetView with UserSettingPopupMenuMixin, NetworkConnectio
|
|||||||
(failure) => SizedBox.shrink(),
|
(failure) => SizedBox.shrink(),
|
||||||
(success) {
|
(success) {
|
||||||
if (success is LoadingState) {
|
if (success is LoadingState) {
|
||||||
return Padding(
|
return Align(alignment: Alignment.topCenter, child: Padding(
|
||||||
padding: EdgeInsets.all(16),
|
padding: EdgeInsets.all(16),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 30,
|
width: 30,
|
||||||
height: 30,
|
height: 30,
|
||||||
child: CupertinoActivityIndicator(color: AppColor.colorLoading)));
|
child: CupertinoActivityIndicator(color: AppColor.colorLoading))));
|
||||||
} else {
|
} else {
|
||||||
if (emailController.emailContents.isNotEmpty) {
|
if (emailController.emailContents.isNotEmpty) {
|
||||||
final allEmailContents = emailController.emailContents.asHtmlString;
|
final allEmailContents = emailController.emailContents.asHtmlString;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2022-04-07T15:43:45.603676",
|
"@@last_modified": "2022-04-14T15:13:36.565629",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -214,12 +214,6 @@
|
|||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
"move_to_mailbox": "Move to mailbox",
|
|
||||||
"@move_to_mailbox": {
|
|
||||||
"type": "text",
|
|
||||||
"placeholders_order": [],
|
|
||||||
"placeholders": {}
|
|
||||||
},
|
|
||||||
"mark_as_star": "Star",
|
"mark_as_star": "Star",
|
||||||
"@mark_as_star": {
|
"@mark_as_star": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -1041,5 +1035,29 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"exchange": "Exchange",
|
||||||
|
"@exchange": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"move_message": "Move message",
|
||||||
|
"@move_message": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"forwarded_message": "Forwarded message",
|
||||||
|
"@forwarded_message": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"date": "Date",
|
||||||
|
"@date": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1097,4 +1097,18 @@ class AppLocalizations {
|
|||||||
name: 'move_message',
|
name: 'move_message',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get forwarded_message {
|
||||||
|
return Intl.message(
|
||||||
|
'Forwarded message',
|
||||||
|
name: 'forwarded_message',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get date {
|
||||||
|
return Intl.message(
|
||||||
|
'Date',
|
||||||
|
name: 'date',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user