TF-2930 Fix inline attachment lost in draft emails
This commit is contained in:
@@ -18,6 +18,7 @@ extension DetailedEmailExtension on DetailedEmail {
|
||||
emailContentPath: emailContentPath,
|
||||
messageId: messageId?.ids.toList(),
|
||||
references: references?.ids.toList(),
|
||||
inlineImages: inlineImages?.toHiveCache(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,6 +37,7 @@ extension DetailedEmailExtension on DetailedEmail {
|
||||
emailContentPath: path,
|
||||
messageId: messageId,
|
||||
references: references,
|
||||
inlineImages: inlineImages,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,8 @@ extension DetailedEmailHiveCacheExtension on DetailedEmailHiveCache {
|
||||
: null,
|
||||
references: references != null
|
||||
? MessageIdsHeaderValue(references!.toSet())
|
||||
: null
|
||||
: null,
|
||||
inlineImages: inlineImages?.toAttachment(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,8 @@ extension EmailExtension on Email {
|
||||
keywords: keywords,
|
||||
htmlEmailContent: htmlEmailContent,
|
||||
messageId: messageId,
|
||||
references: references
|
||||
references: references,
|
||||
inlineImages: allAttachments.listAttachmentsDisplayedInContent,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class DetailedEmail with EquatableMixin {
|
||||
final DateTime createdTime;
|
||||
final MessageIdsHeaderValue? messageId;
|
||||
final MessageIdsHeaderValue? references;
|
||||
final List<Attachment>? inlineImages;
|
||||
|
||||
DetailedEmail({
|
||||
required this.emailId,
|
||||
@@ -25,6 +26,7 @@ class DetailedEmail with EquatableMixin {
|
||||
this.emailContentPath,
|
||||
this.messageId,
|
||||
this.references,
|
||||
this.inlineImages,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -38,5 +40,6 @@ class DetailedEmail with EquatableMixin {
|
||||
emailContentPath,
|
||||
messageId,
|
||||
references,
|
||||
inlineImages,
|
||||
];
|
||||
}
|
||||
@@ -7,12 +7,14 @@ class GetEmailContentLoading extends LoadingState {}
|
||||
|
||||
class GetEmailContentSuccess extends UIState {
|
||||
final String htmlEmailContent;
|
||||
final List<Attachment> attachments;
|
||||
final List<Attachment>? attachments;
|
||||
final List<Attachment>? inlineImages;
|
||||
final Email? emailCurrent;
|
||||
|
||||
GetEmailContentSuccess({
|
||||
required this.htmlEmailContent,
|
||||
required this.attachments,
|
||||
this.attachments,
|
||||
this.inlineImages,
|
||||
this.emailCurrent
|
||||
});
|
||||
|
||||
@@ -20,18 +22,21 @@ class GetEmailContentSuccess extends UIState {
|
||||
List<Object?> get props => [
|
||||
htmlEmailContent,
|
||||
attachments,
|
||||
inlineImages,
|
||||
emailCurrent
|
||||
];
|
||||
}
|
||||
|
||||
class GetEmailContentFromCacheSuccess extends UIState {
|
||||
final String htmlEmailContent;
|
||||
final List<Attachment> attachments;
|
||||
final List<Attachment>? attachments;
|
||||
final List<Attachment>? inlineImages;
|
||||
final Email? emailCurrent;
|
||||
|
||||
GetEmailContentFromCacheSuccess({
|
||||
required this.htmlEmailContent,
|
||||
required this.attachments,
|
||||
this.attachments,
|
||||
this.inlineImages,
|
||||
this.emailCurrent
|
||||
});
|
||||
|
||||
@@ -39,6 +44,7 @@ class GetEmailContentFromCacheSuccess extends UIState {
|
||||
List<Object?> get props => [
|
||||
htmlEmailContent,
|
||||
attachments,
|
||||
inlineImages,
|
||||
emailCurrent,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -47,9 +47,11 @@ class GetEmailContentInteractor {
|
||||
) async* {
|
||||
try {
|
||||
final email = await emailRepository.getEmailContent(session, accountId, emailId);
|
||||
final listAttachments = email.allAttachments.getListAttachmentsDisplayedOutside(email.htmlBodyAttachments);
|
||||
final listInlineImages = email.allAttachments.listAttachmentsDisplayedInContent;
|
||||
|
||||
if (email.emailContentList.isNotEmpty) {
|
||||
final mapCidImageDownloadUrl = email.attachmentsWithCid.toMapCidImageDownloadUrl(
|
||||
final mapCidImageDownloadUrl = listInlineImages.toMapCidImageDownloadUrl(
|
||||
accountId: accountId,
|
||||
downloadUrl: baseDownloadUrl
|
||||
);
|
||||
@@ -61,13 +63,15 @@ class GetEmailContentInteractor {
|
||||
|
||||
yield Right<Failure, Success>(GetEmailContentSuccess(
|
||||
htmlEmailContent: newEmailContents.asHtmlString,
|
||||
attachments: email.allAttachments.getListAttachmentsDisplayedOutside(email.htmlBodyAttachments),
|
||||
attachments: listAttachments,
|
||||
inlineImages: listInlineImages,
|
||||
emailCurrent: email
|
||||
));
|
||||
} else {
|
||||
yield Right<Failure, Success>(GetEmailContentSuccess(
|
||||
htmlEmailContent: '',
|
||||
attachments: email.allAttachments.getListAttachmentsDisplayedOutside(email.htmlBodyAttachments),
|
||||
attachments: listAttachments,
|
||||
inlineImages: listInlineImages,
|
||||
emailCurrent: email
|
||||
));
|
||||
}
|
||||
@@ -90,6 +94,7 @@ class GetEmailContentInteractor {
|
||||
yield Right<Failure, Success>(GetEmailContentFromCacheSuccess(
|
||||
htmlEmailContent: detailedEmail.htmlEmailContent ?? '',
|
||||
attachments: detailedEmail.attachments ?? [],
|
||||
inlineImages: detailedEmail.inlineImages ?? [],
|
||||
emailCurrent: Email(
|
||||
id: emailId,
|
||||
headers: detailedEmail.headers,
|
||||
@@ -121,6 +126,7 @@ class GetEmailContentInteractor {
|
||||
yield Right<Failure, Success>(GetEmailContentFromCacheSuccess(
|
||||
htmlEmailContent: detailedEmail.htmlEmailContent ?? '',
|
||||
attachments: detailedEmail.attachments ?? [],
|
||||
inlineImages: detailedEmail.inlineImages ?? [],
|
||||
emailCurrent: Email(
|
||||
id: emailId,
|
||||
headers: detailedEmail.headers,
|
||||
|
||||
@@ -57,7 +57,7 @@ class GetListDetailedEmailByIdInteractor {
|
||||
|
||||
final listEmailContent = email.emailContentList;
|
||||
if (listEmailContent.isNotEmpty) {
|
||||
final mapCidImageDownloadUrl = email.attachmentsWithCid.toMapCidImageDownloadUrl(
|
||||
final mapCidImageDownloadUrl = email.allAttachments.listAttachmentsDisplayedInContent.toMapCidImageDownloadUrl(
|
||||
accountId: accountId,
|
||||
downloadUrl: baseDownloadUrl
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user