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);
listCcEmailAddress = List.from(recipients.value2);
listBccEmailAddress = List.from(recipients.value3);
listReplyToEmailAddress = List.from(recipients.value4);
if (listToEmailAddress.isNotEmpty || listCcEmailAddress.isNotEmpty || listBccEmailAddress.isNotEmpty || listReplyToEmailAddress.isNotEmpty) {
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';
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,
bool isSender = false,
String? userName,
@@ -21,10 +21,17 @@ extension PresentationEmailExtension on PresentationEmail {
switch (emailActionType) {
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);
return Tuple3(listReplyAddressWithoutUsername, [], []);
return Tuple4(listReplyAddressWithoutUsername, [], [], []);
case EmailActionType.replyToList:
final recipientRecord = EmailUtils.extractRecipientsFromListPost(listPost ?? '');
@@ -43,10 +50,11 @@ extension PresentationEmailExtension on PresentationEmail {
.removeDuplicateEmails()
.withoutMe(userName);
return Tuple3(
return Tuple4(
listToAddressWithoutUsername,
listCcAddressWithoutUsername,
listBccAddressWithoutUsername,
[]
);
case EmailActionType.replyAll:
final recipientRecord = EmailUtils.extractRecipientsFromListPost(listPost ?? '');
@@ -71,20 +79,26 @@ extension PresentationEmailExtension on PresentationEmail {
.removeDuplicateEmails()
.withoutMe(userName);
return Tuple3(
return Tuple4(
listToAddressWithoutUsername,
listCcAddressWithoutUsername,
listBccAddressWithoutUsername,
[]
);
case EmailActionType.editDraft:
return Tuple4(newToAddress, newCcAddress, newBccAddress, newReplyToAddress);
default:
final listToAddressWithoutUsername = newToAddress.withoutMe(userName);
final listCcAddressWithoutUsername = newCcAddress.withoutMe(userName);
final listBccAddressWithoutUsername = newBccAddress.withoutMe(userName);
return Tuple3(
return Tuple4(
listToAddressWithoutUsername,
listCcAddressWithoutUsername,
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', () {
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(
from: {userBEmailAddress},