TF-3221 Handle mailto with additional cc and bcc

This commit is contained in:
DatDang
2024-10-25 11:28:59 +07:00
committed by Dat H. Pham
parent 51a4a1b9b7
commit 45581e4177
9 changed files with 292 additions and 59 deletions
@@ -629,6 +629,16 @@ class ComposerController extends BaseController
isInitialRecipient.value = true;
toAddressExpandMode.value = ExpandMode.COLLAPSE;
}
if (arguments.cc?.isNotEmpty == true) {
listCcEmailAddress = arguments.cc!;
ccRecipientState.value = PrefixRecipientState.enabled;
ccAddressExpandMode.value = ExpandMode.COLLAPSE;
}
if (arguments.bcc?.isNotEmpty == true) {
bccRecipientState.value = PrefixRecipientState.enabled;
bccAddressExpandMode.value = ExpandMode.COLLAPSE;
listBccEmailAddress = arguments.bcc!;
}
_getEmailContentFromMailtoUri(arguments.body ?? '');
_updateStatusEmailSendButton();
break;
@@ -1729,10 +1739,15 @@ class ComposerController extends BaseController
if (bccRecipientState.value == PrefixRecipientState.disabled) {
bccRecipientState.value = PrefixRecipientState.enabled;
}
listBccEmailAddress = listEmailAddress.toList();
if (composerArguments.value?.emailActionType == EmailActionType.composeFromMailtoUri) {
listBccEmailAddress = {...listEmailAddress, ...?composerArguments.value?.bcc}.toList();
} else {
listBccEmailAddress = listEmailAddress.toList();
}
toAddressExpandMode.value = ExpandMode.COLLAPSE;
ccAddressExpandMode.value = ExpandMode.COLLAPSE;
bccAddressExpandMode.value = ExpandMode.COLLAPSE;
bccAddressExpandMode.refresh();
_updateStatusEmailSendButton();
}
@@ -1159,13 +1159,21 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
Future<void> openMailToLink(Uri? uri) async {
if (uri == null) return;
final navigationRouter = RouteUtils.generateNavigationRouterFromMailtoLink(uri.toString());
log('SingleEmailController::openMailToLink(): ${uri.toString()}');
String address = uri?.path ?? '';
log('SingleEmailController::openMailToLink(): address: $address');
if (address.isNotEmpty) {
final emailAddress = EmailAddress(null, address);
mailboxDashBoardController.goToComposer(ComposerArguments.fromEmailAddress(emailAddress));
}
if (!RouteUtils.canOpenComposerFromNavigationRouter(navigationRouter)) return;
mailboxDashBoardController.goToComposer(
ComposerArguments.fromMailtoUri(
listEmailAddress: navigationRouter.listEmailAddress,
cc: navigationRouter.cc,
bcc: navigationRouter.bcc,
subject: navigationRouter.subject,
body: navigationRouter.body
)
);
}
void deleteEmailPermanently(BuildContext context, PresentationEmail email) {
@@ -30,6 +30,8 @@ class ComposerArguments extends RouterArguments {
final List<Attachment>? inlineImages;
final bool? hasRequestReadReceipt;
final ScreenDisplayMode displayMode;
final List<EmailAddress>? cc;
final List<EmailAddress>? bcc;
ComposerArguments({
this.emailActionType = EmailActionType.compose,
@@ -49,7 +51,9 @@ class ComposerArguments extends RouterArguments {
this.selectedIdentityId,
this.inlineImages,
this.hasRequestReadReceipt,
this.displayMode = ScreenDisplayMode.normal
this.displayMode = ScreenDisplayMode.normal,
this.cc,
this.bcc,
});
factory ComposerArguments.fromSendingEmail(SendingEmail sendingEmail) =>
@@ -76,13 +80,20 @@ class ComposerArguments extends RouterArguments {
listEmailAddress: [emailAddress]
);
factory ComposerArguments.fromMailtoUri({List<EmailAddress>? listEmailAddress, String? subject, String? body}) =>
ComposerArguments(
emailActionType: EmailActionType.composeFromMailtoUri,
listEmailAddress: listEmailAddress,
subject: subject,
body: body,
);
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(
@@ -193,6 +204,8 @@ class ComposerArguments extends RouterArguments {
inlineImages,
hasRequestReadReceipt,
displayMode,
cc,
bcc,
];
ComposerArguments copyWith({
@@ -214,6 +227,8 @@ class ComposerArguments extends RouterArguments {
List<Attachment>? inlineImages,
bool? hasRequestReadReceipt,
ScreenDisplayMode? displayMode,
List<EmailAddress>? cc,
List<EmailAddress>? bcc,
}) {
return ComposerArguments(
emailActionType: emailActionType ?? this.emailActionType,
@@ -234,6 +249,8 @@ class ComposerArguments extends RouterArguments {
inlineImages: inlineImages ?? this.inlineImages,
hasRequestReadReceipt: hasRequestReadReceipt ?? this.hasRequestReadReceipt,
displayMode: displayMode ?? this.displayMode,
cc: cc ?? this.cc,
bcc: bcc ?? this.bcc,
);
}
}
@@ -460,6 +460,8 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
mailboxDashBoardController.goToComposer(
ComposerArguments.fromMailtoUri(
listEmailAddress: _navigationRouter?.listEmailAddress,
cc: _navigationRouter?.cc,
bcc: _navigationRouter?.bcc,
subject: _navigationRouter?.subject,
body: _navigationRouter?.body
)
@@ -28,7 +28,7 @@ class MailtoUrlController extends ReloadableController {
if (parameters.containsKey('uri')) {
final mailtoArgument = MailtoArguments(
session: session,
mailtoUri: parameters['uri']
mailtoUri: Uri.base.toString(),
);
popAndPush(
RouteUtils.generateNavigationRoute(AppRoutes.dashboard),