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
|
||||
);
|
||||
|
||||
@@ -469,6 +469,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
GetEmailContentSuccess(
|
||||
htmlEmailContent: emailLoaded.htmlContent,
|
||||
attachments: emailLoaded.attachments,
|
||||
inlineImages: emailLoaded.inlineImages,
|
||||
emailCurrent: emailLoaded.emailCurrent
|
||||
)
|
||||
)));
|
||||
@@ -501,22 +502,23 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
currentEmailLoaded.value = EmailLoaded(
|
||||
htmlContent: success.htmlEmailContent,
|
||||
attachments: List.of(success.attachments),
|
||||
attachments: List.of(success.attachments ?? []),
|
||||
inlineImages: List.of(success.inlineImages ?? []),
|
||||
emailCurrent: success.emailCurrent,
|
||||
);
|
||||
emailSupervisorController.pushEmailQueue(currentEmailLoaded.value!);
|
||||
|
||||
if (success.emailCurrent?.id == currentEmail?.id) {
|
||||
attachments.value = success.attachments;
|
||||
attachments.value = success.attachments ?? [];
|
||||
attachmentsViewState.value = {
|
||||
for (var attachment in attachments.where((item) => item.blobId != null))
|
||||
attachment.blobId!: Right(IdleDownloadAttachmentForWeb())
|
||||
};
|
||||
|
||||
if (_canParseCalendarEvent(blobIds: success.attachments.calendarEventBlobIds)) {
|
||||
if (_canParseCalendarEvent(blobIds: success.attachments?.calendarEventBlobIds ?? {})) {
|
||||
_parseCalendarEventAction(
|
||||
accountId: mailboxDashBoardController.accountId.value!,
|
||||
blobIds: success.attachments.calendarEventBlobIds,
|
||||
blobIds: success.attachments?.calendarEventBlobIds ?? {},
|
||||
emailContents: success.htmlEmailContent
|
||||
);
|
||||
} else {
|
||||
@@ -545,22 +547,23 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
currentEmailLoaded.value = EmailLoaded(
|
||||
htmlContent: success.htmlEmailContent,
|
||||
attachments: List.of(success.attachments),
|
||||
attachments: List.of(success.attachments ?? []),
|
||||
inlineImages: List.of(success.inlineImages ?? []),
|
||||
emailCurrent: success.emailCurrent,
|
||||
);
|
||||
emailSupervisorController.pushEmailQueue(currentEmailLoaded.value!);
|
||||
|
||||
if (success.emailCurrent?.id == currentEmail?.id) {
|
||||
attachments.value = success.attachments;
|
||||
attachments.value = success.attachments ?? [];
|
||||
attachmentsViewState.value = {
|
||||
for (var attachment in attachments.where((item) => item.blobId != null))
|
||||
attachment.blobId!: Right(IdleDownloadAttachmentForWeb())
|
||||
};
|
||||
|
||||
if (_canParseCalendarEvent(blobIds: success.attachments.calendarEventBlobIds)) {
|
||||
if (_canParseCalendarEvent(blobIds: success.attachments?.calendarEventBlobIds ?? {})) {
|
||||
_parseCalendarEventAction(
|
||||
accountId: mailboxDashBoardController.accountId.value!,
|
||||
blobIds: success.attachments.calendarEventBlobIds,
|
||||
blobIds: success.attachments?.calendarEventBlobIds ?? {},
|
||||
emailContents: success.htmlEmailContent
|
||||
);
|
||||
} else {
|
||||
@@ -1343,6 +1346,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
ComposerArguments.replyEmail(
|
||||
presentationEmail: presentationEmail,
|
||||
content: currentEmailLoaded.value?.htmlContent ?? '',
|
||||
inlineImages: currentEmailLoaded.value?.inlineImages ?? [],
|
||||
mailboxRole: presentationEmail.mailboxContain?.role,
|
||||
messageId: currentEmailLoaded.value?.emailCurrent?.messageId,
|
||||
references: currentEmailLoaded.value?.emailCurrent?.references,
|
||||
@@ -1354,6 +1358,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
ComposerArguments.replyAllEmail(
|
||||
presentationEmail: presentationEmail,
|
||||
content: currentEmailLoaded.value?.htmlContent ?? '',
|
||||
inlineImages: currentEmailLoaded.value?.inlineImages ?? [],
|
||||
mailboxRole: presentationEmail.mailboxContain?.role,
|
||||
messageId: currentEmailLoaded.value?.emailCurrent?.messageId,
|
||||
references: currentEmailLoaded.value?.emailCurrent?.references,
|
||||
@@ -1366,6 +1371,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
presentationEmail: presentationEmail,
|
||||
content: currentEmailLoaded.value?.htmlContent ?? '',
|
||||
attachments: attachments,
|
||||
inlineImages: currentEmailLoaded.value?.inlineImages ?? [],
|
||||
messageId: currentEmailLoaded.value?.emailCurrent?.messageId,
|
||||
references: currentEmailLoaded.value?.emailCurrent?.references,
|
||||
)
|
||||
|
||||
@@ -95,11 +95,9 @@ class ComposerArguments extends RouterArguments {
|
||||
emailActionType: EmailActionType.reopenComposerBrowser,
|
||||
presentationEmail: composerCache.email?.toPresentationEmail(),
|
||||
emailContents: composerCache.email?.emailContentList.asHtmlString,
|
||||
attachments: composerCache.email?.allAttachments
|
||||
.where((attachment) => attachment.disposition != ContentDisposition.inline)
|
||||
.toList(),
|
||||
attachments: composerCache.email?.allAttachments.getListAttachmentsDisplayedOutside(composerCache.email?.htmlBodyAttachments ?? []),
|
||||
selectedIdentity: composerCache.identity,
|
||||
inlineImages: composerCache.email?.attachmentsWithCid,
|
||||
inlineImages: composerCache.email?.allAttachments.listAttachmentsDisplayedInContent,
|
||||
readRecepientEnabled: composerCache.readReceipentEnabled,
|
||||
displayMode: composerCache.displayMode,
|
||||
);
|
||||
@@ -107,6 +105,7 @@ class ComposerArguments extends RouterArguments {
|
||||
factory ComposerArguments.replyEmail({
|
||||
required PresentationEmail presentationEmail,
|
||||
required String content,
|
||||
required List<Attachment> inlineImages,
|
||||
Role? mailboxRole,
|
||||
MessageIdsHeaderValue? messageId,
|
||||
MessageIdsHeaderValue? references,
|
||||
@@ -114,6 +113,7 @@ class ComposerArguments extends RouterArguments {
|
||||
emailActionType: EmailActionType.reply,
|
||||
presentationEmail: presentationEmail,
|
||||
emailContents: content,
|
||||
inlineImages: inlineImages,
|
||||
mailboxRole: mailboxRole,
|
||||
messageId: messageId,
|
||||
references: references,
|
||||
@@ -122,6 +122,7 @@ class ComposerArguments extends RouterArguments {
|
||||
factory ComposerArguments.replyAllEmail({
|
||||
required PresentationEmail presentationEmail,
|
||||
required String content,
|
||||
required List<Attachment> inlineImages,
|
||||
Role? mailboxRole,
|
||||
MessageIdsHeaderValue? messageId,
|
||||
MessageIdsHeaderValue? references,
|
||||
@@ -129,6 +130,7 @@ class ComposerArguments extends RouterArguments {
|
||||
emailActionType: EmailActionType.replyAll,
|
||||
presentationEmail: presentationEmail,
|
||||
emailContents: content,
|
||||
inlineImages: inlineImages,
|
||||
mailboxRole: mailboxRole,
|
||||
messageId: messageId,
|
||||
references: references,
|
||||
@@ -138,6 +140,7 @@ class ComposerArguments extends RouterArguments {
|
||||
required PresentationEmail presentationEmail,
|
||||
required String content,
|
||||
required List<Attachment> attachments,
|
||||
required List<Attachment> inlineImages,
|
||||
MessageIdsHeaderValue? messageId,
|
||||
MessageIdsHeaderValue? references,
|
||||
}) => ComposerArguments(
|
||||
@@ -145,6 +148,7 @@ class ComposerArguments extends RouterArguments {
|
||||
presentationEmail: presentationEmail,
|
||||
emailContents: content,
|
||||
attachments: attachments,
|
||||
inlineImages: inlineImages,
|
||||
mailboxRole: presentationEmail.mailboxContain?.role,
|
||||
messageId: messageId,
|
||||
references: references,
|
||||
|
||||
@@ -5,11 +5,13 @@ import 'package:model/email/attachment.dart';
|
||||
class EmailLoaded with EquatableMixin {
|
||||
final String htmlContent;
|
||||
final List<Attachment> attachments;
|
||||
final List<Attachment> inlineImages;
|
||||
final Email? emailCurrent;
|
||||
|
||||
EmailLoaded({
|
||||
required this.htmlContent,
|
||||
required this.attachments,
|
||||
required this.inlineImages,
|
||||
this.emailCurrent,
|
||||
});
|
||||
|
||||
@@ -17,6 +19,7 @@ class EmailLoaded with EquatableMixin {
|
||||
List<Object?> get props => [
|
||||
htmlContent,
|
||||
attachments,
|
||||
inlineImages,
|
||||
emailCurrent
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user