TF-138 Add domain layer for search mail with text pattern
This commit is contained in:
@@ -5,8 +5,8 @@ import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:model/mailbox/select_mode.dart';
|
||||
import 'package:model/extensions/email_address_extension.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class PresentationEmail with EquatableMixin {
|
||||
|
||||
@@ -23,6 +23,8 @@ class PresentationEmail with EquatableMixin {
|
||||
final Set<EmailAddress>? cc;
|
||||
final Set<EmailAddress>? bcc;
|
||||
final Set<EmailAddress>? replyTo;
|
||||
final Map<MailboxId, bool>? mailboxIds;
|
||||
final List<MailboxName?>? mailboxNames;
|
||||
final SelectMode selectMode;
|
||||
|
||||
PresentationEmail(
|
||||
@@ -40,6 +42,8 @@ class PresentationEmail with EquatableMixin {
|
||||
this.cc,
|
||||
this.bcc,
|
||||
this.replyTo,
|
||||
this.mailboxIds,
|
||||
this.mailboxNames,
|
||||
this.selectMode = SelectMode.INACTIVE
|
||||
}
|
||||
);
|
||||
@@ -65,6 +69,8 @@ class PresentationEmail with EquatableMixin {
|
||||
|
||||
bool isFlaggedEmail() => keywords?.containsKey(KeyWordIdentifier.emailFlagged) == true;
|
||||
|
||||
String get mailboxName => mailboxNames?.first?.name ?? '';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
|
||||
@@ -57,6 +57,7 @@ extension EmailExtension on Email {
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo,
|
||||
mailboxIds: mailboxIds,
|
||||
selectMode: selectMode
|
||||
);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo,
|
||||
mailboxIds: mailboxIds,
|
||||
mailboxNames: mailboxNames,
|
||||
selectMode: selectMode == SelectMode.INACTIVE ? SelectMode.ACTIVE : SelectMode.INACTIVE
|
||||
);
|
||||
}
|
||||
@@ -53,6 +55,8 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo,
|
||||
mailboxIds: mailboxIds,
|
||||
mailboxNames: mailboxNames,
|
||||
selectMode: selectMode
|
||||
);
|
||||
}
|
||||
@@ -102,4 +106,37 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
return Tuple3([], [], []);
|
||||
}
|
||||
}
|
||||
|
||||
PresentationEmail toSearchPresentationEmail(Map<MailboxId, PresentationMailbox> mapMailboxes) {
|
||||
mailboxIds?.removeWhere((key, value) => !value);
|
||||
|
||||
final listMailboxId = mailboxIds?.entries
|
||||
.where((entry) => entry.value)
|
||||
.map((entry) => entry.key)
|
||||
.toList();
|
||||
|
||||
final listMailboxName = listMailboxId
|
||||
?.map((mailboxId) => mapMailboxes.containsKey(mailboxId) ? mapMailboxes[mailboxId]?.name : null)
|
||||
.where((mailboxName) => mailboxName != null)
|
||||
.toList();
|
||||
|
||||
return PresentationEmail(
|
||||
this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
hasAttachment: hasAttachment,
|
||||
preview: preview,
|
||||
subject: subject,
|
||||
sentAt: sentAt,
|
||||
from: from,
|
||||
to: to,
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo,
|
||||
mailboxIds: mailboxIds,
|
||||
mailboxNames: listMailboxName,
|
||||
selectMode: selectMode
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user