Handle the behaviour of Reply email when user is sender
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/email/email_action_type.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
import 'package:model/extensions/email_address_extension.dart';
|
||||
import 'package:model/extensions/list_email_address_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||
|
||||
@@ -25,6 +27,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
isSender: isSender,
|
||||
newToAddress: newToAddress,
|
||||
newFromAddress: newFromAddress,
|
||||
newBccAddress: newBccAddress,
|
||||
newReplyToAddress: newReplyToAddress,
|
||||
userName: userName,
|
||||
);
|
||||
@@ -52,15 +55,27 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
required bool isSender,
|
||||
required List<EmailAddress> newToAddress,
|
||||
required List<EmailAddress> newFromAddress,
|
||||
required List<EmailAddress> newBccAddress,
|
||||
required List<EmailAddress> newReplyToAddress,
|
||||
String? userName,
|
||||
}) {
|
||||
if (isSender) {
|
||||
return Tuple4(newToAddress, [], [], newReplyToAddress);
|
||||
if (newBccAddress.isNotEmpty) {
|
||||
return Tuple4(newToAddress, [], [], newReplyToAddress);
|
||||
}
|
||||
if (newReplyToAddress.isNotEmpty) {
|
||||
return Tuple4(newReplyToAddress, [], [], []);
|
||||
}
|
||||
if (userName != null) {
|
||||
final userEmail = newToAddress.firstWhereOrNull((address) => address.emailAddress == userName);
|
||||
if (userEmail != null) {
|
||||
return Tuple4([userEmail], [], [], []);
|
||||
}
|
||||
}
|
||||
return Tuple4(newToAddress, [], [], []);
|
||||
}
|
||||
final listToAddress = newReplyToAddress.isNotEmpty
|
||||
? newReplyToAddress.withoutMe(userName)
|
||||
: newFromAddress.withoutMe(userName);
|
||||
|
||||
final listToAddress = (newReplyToAddress.isNotEmpty ? newReplyToAddress : newFromAddress).withoutMe(userName);
|
||||
return Tuple4(listToAddress, [], [], []);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,21 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
cc.numberEmailAddress() +
|
||||
bcc.numberEmailAddress();
|
||||
|
||||
int getCountMailAddressWithoutMe(String userName) =>
|
||||
to.withoutMe(userName).numberEmailAddress() +
|
||||
cc.withoutMe(userName).numberEmailAddress() +
|
||||
bcc.withoutMe(userName).numberEmailAddress() +
|
||||
from.withoutMe(userName).numberEmailAddress();
|
||||
int getCountMailAddressWithoutMe(String userName) {
|
||||
final uniqueEmails = <String>{};
|
||||
final newTo = to ?? {};
|
||||
final newCc = cc ?? {};
|
||||
final newBcc = bcc ?? {};
|
||||
final newFrom = from ?? {};
|
||||
|
||||
for (final email in <EmailAddress>[...newTo, ...newCc, ...newBcc, ...newFrom]) {
|
||||
if (email.emailAddress != userName) {
|
||||
uniqueEmails.add(email.emailAddress);
|
||||
}
|
||||
}
|
||||
|
||||
return uniqueEmails.length;
|
||||
}
|
||||
|
||||
String getReceivedAt(String newLocale, {String? pattern}) {
|
||||
final emailTime = receivedAt;
|
||||
|
||||
Reference in New Issue
Block a user