fixed broken replyTo feature

This commit is contained in:
Florent Azavant
2025-02-12 17:39:08 +01:00
committed by Dat H. Pham
parent c35ea81c95
commit b8b70d26d4
3 changed files with 22 additions and 7 deletions
@@ -869,6 +869,7 @@ class ComposerController extends BaseController
listToEmailAddress = List.from(recipients.value1); listToEmailAddress = List.from(recipients.value1);
listCcEmailAddress = List.from(recipients.value2); listCcEmailAddress = List.from(recipients.value2);
listBccEmailAddress = List.from(recipients.value3); listBccEmailAddress = List.from(recipients.value3);
listReplyToEmailAddress = List.from(recipients.value4);
if (listToEmailAddress.isNotEmpty || listCcEmailAddress.isNotEmpty || listBccEmailAddress.isNotEmpty || listReplyToEmailAddress.isNotEmpty) { if (listToEmailAddress.isNotEmpty || listCcEmailAddress.isNotEmpty || listBccEmailAddress.isNotEmpty || listReplyToEmailAddress.isNotEmpty) {
isInitialRecipient.value = true; isInitialRecipient.value = true;
@@ -7,7 +7,7 @@ import 'package:model/extensions/list_email_address_extension.dart';
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart'; import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
extension PresentationEmailExtension on PresentationEmail { extension PresentationEmailExtension on PresentationEmail {
Tuple3<List<EmailAddress>, List<EmailAddress>, List<EmailAddress>> generateRecipientsEmailAddressForComposer({ Tuple4<List<EmailAddress>, List<EmailAddress>, List<EmailAddress>, List<EmailAddress>> generateRecipientsEmailAddressForComposer({
required EmailActionType emailActionType, required EmailActionType emailActionType,
bool isSender = false, bool isSender = false,
String? userName, String? userName,
@@ -21,10 +21,17 @@ extension PresentationEmailExtension on PresentationEmail {
switch (emailActionType) { switch (emailActionType) {
case EmailActionType.reply: case EmailActionType.reply:
final listReplyAddress = isSender ? newToAddress : newFromAddress; List<EmailAddress> listReplyAddress;
if (newReplyToAddress.isNotEmpty) {
listReplyAddress = newReplyToAddress;
} else if (isSender) {
listReplyAddress = newToAddress;
} else {
listReplyAddress = newFromAddress;
}
final listReplyAddressWithoutUsername = listReplyAddress.withoutMe(userName); final listReplyAddressWithoutUsername = listReplyAddress.withoutMe(userName);
return Tuple3(listReplyAddressWithoutUsername, [], []); return Tuple4(listReplyAddressWithoutUsername, [], [], []);
case EmailActionType.replyToList: case EmailActionType.replyToList:
final recipientRecord = EmailUtils.extractRecipientsFromListPost(listPost ?? ''); final recipientRecord = EmailUtils.extractRecipientsFromListPost(listPost ?? '');
@@ -43,10 +50,11 @@ extension PresentationEmailExtension on PresentationEmail {
.removeDuplicateEmails() .removeDuplicateEmails()
.withoutMe(userName); .withoutMe(userName);
return Tuple3( return Tuple4(
listToAddressWithoutUsername, listToAddressWithoutUsername,
listCcAddressWithoutUsername, listCcAddressWithoutUsername,
listBccAddressWithoutUsername, listBccAddressWithoutUsername,
[]
); );
case EmailActionType.replyAll: case EmailActionType.replyAll:
final recipientRecord = EmailUtils.extractRecipientsFromListPost(listPost ?? ''); final recipientRecord = EmailUtils.extractRecipientsFromListPost(listPost ?? '');
@@ -71,20 +79,26 @@ extension PresentationEmailExtension on PresentationEmail {
.removeDuplicateEmails() .removeDuplicateEmails()
.withoutMe(userName); .withoutMe(userName);
return Tuple3( return Tuple4(
listToAddressWithoutUsername, listToAddressWithoutUsername,
listCcAddressWithoutUsername, listCcAddressWithoutUsername,
listBccAddressWithoutUsername, listBccAddressWithoutUsername,
[]
); );
case EmailActionType.editDraft:
return Tuple4(newToAddress, newCcAddress, newBccAddress, newReplyToAddress);
default: default:
final listToAddressWithoutUsername = newToAddress.withoutMe(userName); final listToAddressWithoutUsername = newToAddress.withoutMe(userName);
final listCcAddressWithoutUsername = newCcAddress.withoutMe(userName); final listCcAddressWithoutUsername = newCcAddress.withoutMe(userName);
final listBccAddressWithoutUsername = newBccAddress.withoutMe(userName); final listBccAddressWithoutUsername = newBccAddress.withoutMe(userName);
return Tuple3( return Tuple4(
listToAddressWithoutUsername, listToAddressWithoutUsername,
listCcAddressWithoutUsername, listCcAddressWithoutUsername,
listBccAddressWithoutUsername, listBccAddressWithoutUsername,
[]
); );
} }
} }
@@ -62,7 +62,7 @@ void main() {
group('GIVEN user B is the sender, SENDER configured the replyTo email AND send an email to user A and user E, cc to user C, bcc to user D', () { group('GIVEN user B is the sender, SENDER configured the replyTo email AND send an email to user A and user E, cc to user C, bcc to user D', () {
test('THEN user A click reply, generateRecipientsEmailAddressForComposer SHOULD return only replyToEmailAddress email to reply' , () { test('THEN user A click reply, generateRecipientsEmailAddressForComposer SHOULD return only replyToEmailAddress email to reply' , () {
final expectedResult = Tuple3([userBEmailAddress], <EmailAddress>[], <EmailAddress>[]); final expectedResult = Tuple3([replyToEmailAddress], <EmailAddress>[], <EmailAddress>[]);
final emailToReply = PresentationEmail( final emailToReply = PresentationEmail(
from: {userBEmailAddress}, from: {userBEmailAddress},