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