Files
workavia-mail-front/lib/features/email/presentation/model/composer_arguments.dart
T
DatDang 8a2ea62987 TF-3715 Thread Detail create resuable actions
TF-3715 Thread Detail refactor actions for expanded email view

TF-3715 Thread Detail apply actions for collapsed email view

TF-3715 Thread Detail fix unit tests

TF-3715 Thread Detail add await for _getEmailContent in composer

TF-3715 Thread Detail remove unused emailLoaded in ThreadDetailAppBar

TF-3715 Thread Detail hide print action when isMobile

TF-3715 Thread Detail allow mark as read in EmailActionReactor

TF-3715 Thread Detail fix loadMoreThreadDetailEmails unit test

TF-3715 Thread Detail fix action small tap region

TF-3715 Thread Detail fix cannot permanent delete email

TF-3715 Thread Detail prevent close when move email

TF-3715 Thread Detail fix refresh when mark star selected collapsed email

TF-3715 Thread Detail update print action display logic

TF-3715 Thread Detail fix duplicate mark star in app bar

TF-3715 Thread Detail create new transformer for reply forward empty content email

TF-3715 Thread Detail fix email not load after open multiple times

TF-3715 Thread Detail fix close when move expanded email

TF-3715 Thread Detail fix duplicate and missing actions

TF-3715 Thread Detail restore editAsNewEmail action to _getEmailContent in setupEmailContent

TF-3715 Thread Detail update print action name

TF-3715 Thread Detail handle move and delete email with 1 item in thread detail

TF-3715 Thread Detail fix tap outside to close context menu

TF-3715 Thread Detail fix create rule and compose from recipient info

TF-3715 Thread Detail handle move and delete email with 1 item in thread detail

TF-3715 Thread Detail Fix cannot create email rule

TF-3715 Thread Detail Fix crash composer

TF-3715 Thread Detail Fix cannot unsubscribe

TF-3715 Thread Detail Fix duplicate actions on single email

TF-3715 Thread Detail Fix refresh view when reply/forward

TF-3715 Thread Detail Revert old logic to _getEmailContent

TF-3715 Thread Detail Update specific cases for UpdatedEmailKeywordsAction

TF-3715 Thread Detail Fix concurrent modification during iteration

TF-3715 Thread Detail Fix unsubscribe for all thread detail emails

TF-3715 Thread Detail Remove unnecessary Future in reactor

TF-3715 Thread Detail Remove dependency from SingleEmailController

TF-3715 Thread Detail Apply individual list post and unsubscribe header

TF-3715 Thread Detail Fix unsubscribe collapsed email

TF-3715 Thread Detail Conditionally inject rule filter interactor
2025-07-21 05:34:53 +07:00

330 lines
11 KiB
Dart

import 'package:jmap_dart_client/jmap/identities/identity.dart';
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
import 'package:model/model.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/data/model/composer_cache.dart';
import 'package:tmail_ui_user/features/sending_queue/domain/model/sending_email.dart';
import 'package:tmail_ui_user/features/sending_queue/presentation/model/sending_email_action_type.dart';
import 'package:tmail_ui_user/main/routes/router_arguments.dart';
class ComposerArguments extends RouterArguments {
final EmailActionType emailActionType;
final PresentationEmail? presentationEmail;
final String? emailContents;
final List<SharedMediaFile>? listSharedMediaFile;
final List<EmailAddress>? listEmailAddress;
final List<Attachment>? attachments;
final Role? mailboxRole;
final SendingEmail? sendingEmail;
final String? subject;
final String? body;
final MessageIdsHeaderValue? messageId;
final MessageIdsHeaderValue? references;
final EmailId? previousEmailId;
final List<Identity>? identities;
final IdentityId? selectedIdentityId;
final List<Attachment>? inlineImages;
final bool? hasRequestReadReceipt;
final bool? isMarkAsImportant;
final ScreenDisplayMode displayMode;
final List<EmailAddress>? cc;
final List<EmailAddress>? bcc;
final String? listPost;
final String? composerId;
final int? savedDraftHash;
final EmailActionType? savedActionType;
final EmailId? savedEmailDraftId;
final EmailId? savedEmailTemplateId;
ComposerArguments({
this.emailActionType = EmailActionType.compose,
this.presentationEmail,
this.emailContents,
this.attachments,
this.mailboxRole,
this.listEmailAddress,
this.listSharedMediaFile,
this.sendingEmail,
this.subject,
this.body,
this.messageId,
this.references,
this.previousEmailId,
this.identities,
this.selectedIdentityId,
this.inlineImages,
this.hasRequestReadReceipt,
this.displayMode = ScreenDisplayMode.normal,
this.cc,
this.bcc,
this.listPost,
this.isMarkAsImportant,
this.composerId,
this.savedDraftHash,
this.savedActionType,
this.savedEmailDraftId,
this.savedEmailTemplateId,
});
factory ComposerArguments.fromSendingEmail(SendingEmail sendingEmail) =>
ComposerArguments(
emailActionType: EmailActionType.editSendingEmail,
sendingEmail: sendingEmail
);
factory ComposerArguments.fromContentShared(String content) =>
ComposerArguments(
emailActionType: EmailActionType.composeFromContentShared,
emailContents: content
);
factory ComposerArguments.fromFileShared(List<SharedMediaFile> filesShared) =>
ComposerArguments(
emailActionType: EmailActionType.composeFromFileShared,
listSharedMediaFile: filesShared
);
factory ComposerArguments.fromEmailAddress(EmailAddress emailAddress) =>
ComposerArguments(
emailActionType: EmailActionType.composeFromEmailAddress,
listEmailAddress: [emailAddress]
);
factory ComposerArguments.fromMailtoUri({
List<EmailAddress>? listEmailAddress,
String? subject,
String? body,
List<EmailAddress>? cc,
List<EmailAddress>? bcc
}) => ComposerArguments(
emailActionType: EmailActionType.composeFromMailtoUri,
listEmailAddress: listEmailAddress,
subject: subject,
body: body,
cc: cc,
bcc: bcc,
);
factory ComposerArguments.editDraftEmail(PresentationEmail presentationEmail) =>
ComposerArguments(
emailActionType: EmailActionType.editDraft,
presentationEmail: presentationEmail,
);
factory ComposerArguments.editAsNewEmail(
PresentationEmail presentationEmail, {
EmailId? savedEmailTemplateId
}) => ComposerArguments(
emailActionType: EmailActionType.editAsNewEmail,
presentationEmail: presentationEmail,
savedEmailTemplateId: savedEmailTemplateId,
);
factory ComposerArguments.fromSessionStorageBrowser(ComposerCache composerCache) =>
ComposerArguments(
emailActionType: EmailActionType.reopenComposerBrowser,
presentationEmail: composerCache.email?.toPresentationEmail(),
emailContents: composerCache.email?.emailContentList.asHtmlString,
attachments: composerCache.email?.allAttachments.getListAttachmentsDisplayedOutside(composerCache.email?.htmlBodyAttachments ?? []),
selectedIdentityId: composerCache.email?.identityIdFromHeader,
inlineImages: composerCache.email?.allAttachments.listAttachmentsDisplayedInContent,
hasRequestReadReceipt: composerCache.hasRequestReadReceipt,
displayMode: composerCache.displayMode,
isMarkAsImportant: composerCache.isMarkAsImportant,
composerId: composerCache.composerId,
savedDraftHash: composerCache.draftHash,
savedActionType: composerCache.actionType,
savedEmailDraftId: composerCache.draftEmailId,
savedEmailTemplateId: composerCache.templateEmailId,
);
factory ComposerArguments.replyEmail({
required PresentationEmail presentationEmail,
required String? content,
required List<Attachment>? inlineImages,
Role? mailboxRole,
MessageIdsHeaderValue? messageId,
MessageIdsHeaderValue? references,
String? listPost,
}) => ComposerArguments(
emailActionType: EmailActionType.reply,
presentationEmail: presentationEmail,
emailContents: content,
inlineImages: inlineImages,
mailboxRole: mailboxRole,
messageId: messageId,
references: references,
listPost: listPost,
);
factory ComposerArguments.replyToListEmail({
required PresentationEmail presentationEmail,
required String? content,
required List<Attachment>? inlineImages,
Role? mailboxRole,
MessageIdsHeaderValue? messageId,
MessageIdsHeaderValue? references,
String? listPost,
}) => ComposerArguments(
emailActionType: EmailActionType.replyToList,
presentationEmail: presentationEmail,
emailContents: content,
inlineImages: inlineImages,
mailboxRole: mailboxRole,
messageId: messageId,
references: references,
listPost: listPost,
);
factory ComposerArguments.replyAllEmail({
required PresentationEmail presentationEmail,
required String? content,
required List<Attachment>? inlineImages,
Role? mailboxRole,
MessageIdsHeaderValue? messageId,
MessageIdsHeaderValue? references,
String? listPost,
}) => ComposerArguments(
emailActionType: EmailActionType.replyAll,
presentationEmail: presentationEmail,
emailContents: content,
inlineImages: inlineImages,
mailboxRole: mailboxRole,
messageId: messageId,
references: references,
listPost: listPost,
);
factory ComposerArguments.forwardEmail({
required PresentationEmail presentationEmail,
required String? content,
required List<Attachment>? attachments,
required List<Attachment>? inlineImages,
MessageIdsHeaderValue? messageId,
MessageIdsHeaderValue? references,
}) => ComposerArguments(
emailActionType: EmailActionType.forward,
presentationEmail: presentationEmail,
emailContents: content,
attachments: attachments,
inlineImages: inlineImages,
mailboxRole: presentationEmail.mailboxContain?.role,
messageId: messageId,
references: references,
);
SendingEmailActionType get sendingEmailActionType => sendingEmail != null
? SendingEmailActionType.edit
: SendingEmailActionType.create;
factory ComposerArguments.fromUnsubscribeMailtoLink({
List<EmailAddress>? listEmailAddress,
String? subject,
String? body,
EmailId? previousEmailId
}) =>
ComposerArguments(
emailActionType: EmailActionType.composeFromUnsubscribeMailtoLink,
listEmailAddress: listEmailAddress,
subject: subject,
body: body,
previousEmailId: previousEmailId,
);
@override
List<Object?> get props => [
emailActionType,
presentationEmail,
emailContents,
attachments,
mailboxRole,
listEmailAddress,
listSharedMediaFile,
sendingEmail,
subject,
body,
messageId,
references,
previousEmailId,
identities,
selectedIdentityId,
inlineImages,
hasRequestReadReceipt,
isMarkAsImportant,
displayMode,
cc,
bcc,
listPost,
composerId,
savedDraftHash,
savedActionType,
savedEmailDraftId,
sendingEmailActionType,
];
ComposerArguments copyWith({
EmailActionType? emailActionType,
PresentationEmail? presentationEmail,
String? emailContents,
List<SharedMediaFile>? listSharedMediaFile,
List<EmailAddress>? listEmailAddress,
List<Attachment>? attachments,
Role? mailboxRole,
SendingEmail? sendingEmail,
String? subject,
String? body,
MessageIdsHeaderValue? messageId,
MessageIdsHeaderValue? references,
EmailId? previousEmailId,
List<Identity>? identities,
IdentityId? selectedIdentityId,
List<Attachment>? inlineImages,
bool? hasRequestReadReceipt,
bool? isMarkAsImportant,
ScreenDisplayMode? displayMode,
List<EmailAddress>? cc,
List<EmailAddress>? bcc,
String? listPost,
String? composerId,
int? savedDraftHash,
EmailActionType? savedActionType,
EmailId? savedEmailDraftId,
EmailId? savedEmailTemplateId,
}) {
return ComposerArguments(
emailActionType: emailActionType ?? this.emailActionType,
presentationEmail: presentationEmail ?? this.presentationEmail,
emailContents: emailContents ?? this.emailContents,
listSharedMediaFile: listSharedMediaFile ?? this.listSharedMediaFile,
listEmailAddress: listEmailAddress ?? this.listEmailAddress,
attachments: attachments ?? this.attachments,
mailboxRole: mailboxRole ?? this.mailboxRole,
sendingEmail: sendingEmail ?? this.sendingEmail,
subject: subject ?? this.subject,
body: body ?? this.body,
messageId: messageId ?? this.messageId,
references: references ?? this.references,
previousEmailId: previousEmailId ?? this.previousEmailId,
identities: identities ?? this.identities,
selectedIdentityId: selectedIdentityId ?? this.selectedIdentityId,
inlineImages: inlineImages ?? this.inlineImages,
hasRequestReadReceipt: hasRequestReadReceipt ?? this.hasRequestReadReceipt,
isMarkAsImportant: isMarkAsImportant ?? this.isMarkAsImportant,
displayMode: displayMode ?? this.displayMode,
cc: cc ?? this.cc,
bcc: bcc ?? this.bcc,
listPost: listPost ?? this.listPost,
composerId: composerId ?? this.composerId,
savedDraftHash: savedDraftHash ?? this.savedDraftHash,
savedActionType: savedActionType ?? this.savedActionType,
savedEmailDraftId: savedEmailDraftId ?? this.savedEmailDraftId,
savedEmailTemplateId: savedEmailTemplateId ?? this.savedEmailTemplateId,
);
}
}