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:dartz/dartz.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||||
import 'package:model/email/email_action_type.dart';
|
import 'package:model/email/email_action_type.dart';
|
||||||
import 'package:model/email/presentation_email.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: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';
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
|||||||
isSender: isSender,
|
isSender: isSender,
|
||||||
newToAddress: newToAddress,
|
newToAddress: newToAddress,
|
||||||
newFromAddress: newFromAddress,
|
newFromAddress: newFromAddress,
|
||||||
|
newBccAddress: newBccAddress,
|
||||||
newReplyToAddress: newReplyToAddress,
|
newReplyToAddress: newReplyToAddress,
|
||||||
userName: userName,
|
userName: userName,
|
||||||
);
|
);
|
||||||
@@ -52,15 +55,27 @@ extension PresentationEmailExtension on PresentationEmail {
|
|||||||
required bool isSender,
|
required bool isSender,
|
||||||
required List<EmailAddress> newToAddress,
|
required List<EmailAddress> newToAddress,
|
||||||
required List<EmailAddress> newFromAddress,
|
required List<EmailAddress> newFromAddress,
|
||||||
|
required List<EmailAddress> newBccAddress,
|
||||||
required List<EmailAddress> newReplyToAddress,
|
required List<EmailAddress> newReplyToAddress,
|
||||||
String? userName,
|
String? userName,
|
||||||
}) {
|
}) {
|
||||||
if (isSender) {
|
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)
|
final listToAddress = (newReplyToAddress.isNotEmpty ? newReplyToAddress : newFromAddress).withoutMe(userName);
|
||||||
: newFromAddress.withoutMe(userName);
|
|
||||||
return Tuple4(listToAddress, [], [], []);
|
return Tuple4(listToAddress, [], [], []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,21 @@ extension PresentationEmailExtension on PresentationEmail {
|
|||||||
cc.numberEmailAddress() +
|
cc.numberEmailAddress() +
|
||||||
bcc.numberEmailAddress();
|
bcc.numberEmailAddress();
|
||||||
|
|
||||||
int getCountMailAddressWithoutMe(String userName) =>
|
int getCountMailAddressWithoutMe(String userName) {
|
||||||
to.withoutMe(userName).numberEmailAddress() +
|
final uniqueEmails = <String>{};
|
||||||
cc.withoutMe(userName).numberEmailAddress() +
|
final newTo = to ?? {};
|
||||||
bcc.withoutMe(userName).numberEmailAddress() +
|
final newCc = cc ?? {};
|
||||||
from.withoutMe(userName).numberEmailAddress();
|
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}) {
|
String getReceivedAt(String newLocale, {String? pattern}) {
|
||||||
final emailTime = receivedAt;
|
final emailTime = receivedAt;
|
||||||
|
|||||||
Reference in New Issue
Block a user