TF-103 [BUG] Given a mail in sent box, i open it, click reply, it sends it to myself
This commit is contained in:
@@ -47,7 +47,6 @@ class ComposerController extends BaseController {
|
||||
final expandMode = ExpandMode.COLLAPSE.obs;
|
||||
final composerArguments = Rxn<ComposerArguments>();
|
||||
final isEnableEmailSendButton = false.obs;
|
||||
final listReplyToEmailAddress = <EmailAddress>[].obs;
|
||||
final attachments = <Attachment>[].obs;
|
||||
|
||||
final SendEmailInteractor _sendEmailInteractor;
|
||||
@@ -177,17 +176,28 @@ class ComposerController extends BaseController {
|
||||
}
|
||||
|
||||
void _initToEmailAddress() {
|
||||
if (composerArguments.value != null
|
||||
&& composerArguments.value?.presentationEmail != null
|
||||
&& composerArguments.value?.emailActionType == EmailActionType.reply) {
|
||||
final replyToEmailAddress = composerArguments.value!.presentationEmail?.replyTo;
|
||||
final fromEmailAddress = composerArguments.value!.presentationEmail?.from;
|
||||
if (replyToEmailAddress != null && replyToEmailAddress.isNotEmpty) {
|
||||
listReplyToEmailAddress.value = replyToEmailAddress.toList();
|
||||
} else if (fromEmailAddress != null && fromEmailAddress.isNotEmpty) {
|
||||
listReplyToEmailAddress.value = fromEmailAddress.toList();
|
||||
if (composerArguments.value != null && composerArguments.value?.presentationEmail != null) {
|
||||
final userEmailAddress = EmailAddress(null, composerArguments.value!.userProfile.email);
|
||||
|
||||
final recipients = composerArguments.value!.presentationEmail!.generateRecipientsEmailAddressForComposer(
|
||||
composerArguments.value?.emailActionType,
|
||||
composerArguments.value?.mailboxRole);
|
||||
|
||||
if (composerArguments.value?.mailboxRole == PresentationMailbox.roleSent) {
|
||||
listToEmailAddress = recipients.value1;
|
||||
listCcEmailAddress = recipients.value2;
|
||||
listBccEmailAddress = recipients.value3;
|
||||
} else {
|
||||
listToEmailAddress = recipients.value1.toSet().filterEmailAddress(userEmailAddress);
|
||||
listCcEmailAddress = recipients.value2.toSet().filterEmailAddress(userEmailAddress);
|
||||
listBccEmailAddress = recipients.value3.toSet().filterEmailAddress(userEmailAddress);
|
||||
}
|
||||
|
||||
if (listCcEmailAddress.isNotEmpty || listBccEmailAddress.isNotEmpty) {
|
||||
expandMode.value = ExpandMode.EXPAND;
|
||||
} else {
|
||||
expandMode.value = ExpandMode.COLLAPSE;
|
||||
}
|
||||
listToEmailAddress = listReplyToEmailAddress;
|
||||
}
|
||||
_updateStatusEmailSendButton();
|
||||
}
|
||||
@@ -196,7 +206,6 @@ class ComposerController extends BaseController {
|
||||
switch(prefixEmailAddress) {
|
||||
case PrefixEmailAddress.to:
|
||||
listToEmailAddress = newListEmailAddress;
|
||||
listReplyToEmailAddress.clear();
|
||||
break;
|
||||
case PrefixEmailAddress.cc:
|
||||
listCcEmailAddress = newListEmailAddress;
|
||||
@@ -211,8 +220,7 @@ class ComposerController extends BaseController {
|
||||
void _updateStatusEmailSendButton() {
|
||||
if (listToEmailAddress.isNotEmpty
|
||||
|| listBccEmailAddress.isNotEmpty
|
||||
|| listCcEmailAddress.isNotEmpty
|
||||
|| listReplyToEmailAddress.isNotEmpty) {
|
||||
|| listCcEmailAddress.isNotEmpty) {
|
||||
isEnableEmailSendButton.value = true;
|
||||
} else {
|
||||
isEnableEmailSendButton.value = false;
|
||||
|
||||
@@ -110,7 +110,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
context,
|
||||
imagePaths,
|
||||
controller.expandMode.value,
|
||||
controller.listReplyToEmailAddress.isNotEmpty ? controller.listReplyToEmailAddress : controller.listToEmailAddress,
|
||||
controller.listToEmailAddress,
|
||||
controller.listCcEmailAddress,
|
||||
controller.listBccEmailAddress,
|
||||
controller.composerArguments.value?.userProfile)
|
||||
|
||||
@@ -341,6 +341,7 @@ class EmailController extends BaseController {
|
||||
emailActionType: emailActionType,
|
||||
presentationEmail: mailboxDashBoardController.selectedEmail.value!,
|
||||
emailContent: emailContent.value,
|
||||
mailboxRole: mailboxDashBoardController.selectedMailbox.value?.role,
|
||||
session: mailboxDashBoardController.sessionCurrent!,
|
||||
userProfile: mailboxDashBoardController.userProfile.value!,
|
||||
mapMailboxId: mailboxDashBoardController.mapMailboxId));
|
||||
|
||||
@@ -11,11 +11,13 @@ class ComposerArguments with EquatableMixin {
|
||||
final Session session;
|
||||
final UserProfile userProfile;
|
||||
final Map<Role, MailboxId> mapMailboxId;
|
||||
final Role? mailboxRole;
|
||||
|
||||
ComposerArguments({
|
||||
this.emailActionType = EmailActionType.compose,
|
||||
this.presentationEmail,
|
||||
this.emailContent,
|
||||
this.mailboxRole,
|
||||
required this.session,
|
||||
required this.userProfile,
|
||||
required this.mapMailboxId,
|
||||
@@ -26,6 +28,7 @@ class ComposerArguments with EquatableMixin {
|
||||
emailActionType,
|
||||
presentationEmail,
|
||||
emailContent,
|
||||
mailboxRole,
|
||||
session,
|
||||
userProfile,
|
||||
mapMailboxId,
|
||||
|
||||
@@ -6,6 +6,8 @@ extension ListEmailAddressExtension on Set<EmailAddress>? {
|
||||
|
||||
List<String>? getListAddress() => this?.map((emailAddress) => emailAddress.getEmail()).toList();
|
||||
|
||||
List<EmailAddress> asList() => this != null ? this!.toList() : List.empty();
|
||||
|
||||
List<String> getListEmailAddress({ExpandMode expandMode = ExpandMode.EXPAND, int limitAddress = 1, bool isFullEmailAddress = false}) {
|
||||
if (this != null) {
|
||||
if (expandMode == ExpandMode.EXPAND) {
|
||||
@@ -24,4 +26,11 @@ extension ListEmailAddressExtension on Set<EmailAddress>? {
|
||||
}
|
||||
|
||||
int numberEmailAddress() => this != null ? this!.length : 0;
|
||||
|
||||
List<EmailAddress> filterEmailAddress(EmailAddress emailAddressNotExist) {
|
||||
return this != null
|
||||
? this!.where((emailAddress) => emailAddress.email != emailAddressNotExist.email)
|
||||
.toList()
|
||||
: List.empty();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:dartz/dartz.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';
|
||||
|
||||
extension PresentationEmailExtension on PresentationEmail {
|
||||
@@ -18,7 +21,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
PresentationEmail toggleSelect() {
|
||||
return PresentationEmail(
|
||||
id,
|
||||
this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -37,7 +40,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
PresentationEmail toSelectedEmail({required SelectMode selectMode}) {
|
||||
return PresentationEmail(
|
||||
id,
|
||||
this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -56,7 +59,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
Email toEmail() {
|
||||
return Email(
|
||||
id,
|
||||
this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -75,4 +78,27 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
String recipientsName() {
|
||||
return to.listEmailAddressToString() + cc.listEmailAddressToString() + bcc.listEmailAddressToString();
|
||||
}
|
||||
|
||||
Tuple3<List<EmailAddress>, List<EmailAddress>, List<EmailAddress>> generateRecipientsEmailAddressForComposer(
|
||||
EmailActionType? emailActionType,
|
||||
Role? mailboxRole
|
||||
) {
|
||||
switch(emailActionType) {
|
||||
case EmailActionType.reply:
|
||||
if (mailboxRole == PresentationMailbox.roleSent) {
|
||||
return Tuple3(to.asList(), [], []);
|
||||
} else {
|
||||
final replyToAddress = replyTo.asList().isNotEmpty ? replyTo.asList() : from.asList();
|
||||
return Tuple3(replyToAddress, [], []);
|
||||
}
|
||||
case EmailActionType.replyAll:
|
||||
if (mailboxRole == PresentationMailbox.roleSent) {
|
||||
return Tuple3(to.asList(), cc.asList(), bcc.asList());
|
||||
} else {
|
||||
return Tuple3(to.asList() + from.asList(), cc.asList(), bcc.asList());
|
||||
}
|
||||
default:
|
||||
return Tuple3([], [], []);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user