Hot fix after some reload minimized composer should be lost body

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-03-31 10:01:25 +07:00
committed by Dat H. Pham
parent 89a3743eaf
commit 4e0e92c35b
34 changed files with 1144 additions and 1902 deletions
@@ -190,23 +190,24 @@ class HtmlAnalyzer {
}
Future<String> removeCollapsedExpandedSignatureEffect({required String emailContent}) async {
log('HtmlAnalyzer::removeCollapsedExpandedSignatureEffect: BEFORE = $emailContent');
final document = parse(emailContent);
final signatureElements = document.querySelectorAll('div.tmail-signature');
await Future.wait(signatureElements.map((signatureTag) async {
final signatureChildren = signatureTag.children;
for (var child in signatureChildren) {
log('HtmlAnalyzer::removeCollapsedExpandedSignatureEffect: CHILD = ${child.outerHtml}');
if (child.attributes['class']?.contains('tmail-signature-button') == true) {
child.remove();
} else if (child.attributes['class']?.contains('tmail-signature-content') == true) {
signatureTag.innerHtml = child.innerHtml;
try {
final document = parse(emailContent);
final signatureElements = document.querySelectorAll('div.tmail-signature');
await Future.wait(signatureElements.map((signatureTag) async {
final signatureChildren = signatureTag.children;
for (var child in signatureChildren) {
if (child.attributes['class']?.contains('tmail-signature-button') == true) {
child.remove();
} else if (child.attributes['class']?.contains('tmail-signature-content') == true) {
signatureTag.innerHtml = child.innerHtml;
}
}
}
}));
final newContent = document.body?.innerHtml ?? emailContent;
log('HtmlAnalyzer::removeCollapsedExpandedSignatureEffect: AFTER = $newContent');
return newContent;
}));
return document.body?.innerHtml ?? emailContent;
} catch (e) {
logError('HtmlAnalyzer::removeCollapsedExpandedSignatureEffect:Exception = $e');
return emailContent;
}
}
Future<(Attachment attachment, String taskId)?> _retrieveAttachmentFromUpload({
@@ -31,13 +31,13 @@ class GetEmailContentFromCacheSuccess extends UIState {
final String htmlEmailContent;
final List<Attachment>? attachments;
final List<Attachment>? inlineImages;
final Email? emailCurrent;
final Email emailCurrent;
GetEmailContentFromCacheSuccess({
required this.htmlEmailContent,
required this.emailCurrent,
this.attachments,
this.inlineImages,
this.emailCurrent
});
@override
@@ -619,7 +619,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
if (emailSupervisorController.presentationEmailsLoaded.length > ThreadConstants.defaultLimit.value.toInt()) {
emailSupervisorController.popFirstEmailQueue();
}
emailSupervisorController.popEmailQueue(success.emailCurrent?.id);
emailSupervisorController.popEmailQueue(success.emailCurrent.id);
currentEmailLoaded.value = EmailLoaded(
htmlContent: success.htmlEmailContent,
@@ -629,7 +629,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
);
emailSupervisorController.pushEmailQueue(currentEmailLoaded.value!);
if (success.emailCurrent?.id == currentEmail?.id) {
if (success.emailCurrent.id == currentEmail?.id) {
attachments.value = success.attachments ?? [];
attachmentsViewState.value = {
for (var attachment in attachments.where((item) => item.blobId != null))
@@ -645,13 +645,13 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
emailContents.value = success.htmlEmailContent;
}
final isShowMessageReadReceipt = success.emailCurrent?.hasReadReceipt(mailboxDashBoardController.mapMailboxById) == true;
final isShowMessageReadReceipt = success.emailCurrent.hasReadReceipt(mailboxDashBoardController.mapMailboxById) == true;
if (isShowMessageReadReceipt) {
_handleReadReceipt();
}
if (currentEmail?.isSubscribed == false && success.emailCurrent?.hasListUnsubscribe == true) {
_handleUnsubscribe(success.emailCurrent!.listUnsubscribe);
if (currentEmail?.isSubscribed == false && success.emailCurrent.hasListUnsubscribe == true) {
_handleUnsubscribe(success.emailCurrent.listUnsubscribe);
} else {
emailUnsubscribe.value = null;
}
@@ -35,6 +35,9 @@ class ComposerArguments extends RouterArguments {
final List<EmailAddress>? bcc;
final String? listPost;
final String? composerId;
final int? savedDraftHash;
final EmailActionType? savedActionType;
final EmailId? savedEmailDraftId;
ComposerArguments({
this.emailActionType = EmailActionType.compose,
@@ -60,6 +63,9 @@ class ComposerArguments extends RouterArguments {
this.listPost,
this.isMarkAsImportant,
this.composerId,
this.savedDraftHash,
this.savedActionType,
this.savedEmailDraftId,
});
factory ComposerArguments.fromSendingEmail(SendingEmail sendingEmail) =>
@@ -125,6 +131,9 @@ class ComposerArguments extends RouterArguments {
displayMode: composerCache.displayMode,
isMarkAsImportant: composerCache.isMarkAsImportant,
composerId: composerCache.composerId,
savedDraftHash: composerCache.draftHash,
savedActionType: composerCache.actionType,
savedEmailDraftId: composerCache.draftEmailId,
);
factory ComposerArguments.replyEmail({
@@ -246,6 +255,9 @@ class ComposerArguments extends RouterArguments {
bcc,
listPost,
composerId,
savedDraftHash,
savedActionType,
savedEmailDraftId,
];
ComposerArguments copyWith({
@@ -272,6 +284,9 @@ class ComposerArguments extends RouterArguments {
List<EmailAddress>? bcc,
String? listPost,
String? composerId,
int? savedDraftHash,
EmailActionType? savedActionType,
EmailId? savedEmailDraftId,
}) {
return ComposerArguments(
emailActionType: emailActionType ?? this.emailActionType,
@@ -297,6 +312,9 @@ class ComposerArguments extends RouterArguments {
bcc: bcc ?? this.bcc,
listPost: listPost ?? this.listPost,
composerId: composerId ?? this.composerId,
savedDraftHash: savedDraftHash ?? this.savedDraftHash,
savedActionType: savedActionType ?? this.savedActionType,
savedEmailDraftId: savedEmailDraftId ?? this.savedEmailDraftId,
);
}
}