-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-3235 Create seach emails in thread API, datasource and repository
- Loading branch information
1 parent
12d52fc
commit 990f162
Showing
11 changed files
with
605 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import 'package:jmap_dart_client/jmap/mail/email/email.dart'; | ||
|
||
class SearchEmail extends Email { | ||
final String? searchSnippetSubject; | ||
final String? searchSnippetPreview; | ||
|
||
SearchEmail({ | ||
super.id, | ||
super.blobId, | ||
super.threadId, | ||
super.mailboxIds, | ||
super.keywords, | ||
super.size, | ||
super.receivedAt, | ||
super.headers, | ||
super.messageId, | ||
super.inReplyTo, | ||
super.references, | ||
super.subject, | ||
super.sentAt, | ||
super.hasAttachment, | ||
super.preview, | ||
super.sender, | ||
super.from, | ||
super.to, | ||
super.cc, | ||
super.bcc, | ||
super.replyTo, | ||
super.textBody, | ||
super.htmlBody, | ||
super.attachments, | ||
super.bodyStructure, | ||
super.bodyValues, | ||
super.headerUserAgent, | ||
super.headerMdn, | ||
super.headerCalendarEvent, | ||
super.sMimeStatusHeader, | ||
super.identityHeader, | ||
required this.searchSnippetSubject, | ||
required this.searchSnippetPreview | ||
}); | ||
|
||
@override | ||
List<Object?> get props => [ | ||
...super.props, | ||
searchSnippetSubject, | ||
searchSnippetPreview, | ||
]; | ||
|
||
factory SearchEmail.fromEmail( | ||
Email email, { | ||
String? searchSnippetSubject, | ||
String? searchSnippetPreview, | ||
}) { | ||
return SearchEmail( | ||
id: email.id, | ||
blobId: email.blobId, | ||
threadId: email.threadId, | ||
mailboxIds: email.mailboxIds, | ||
keywords: email.keywords, | ||
size: email.size, | ||
receivedAt: email.receivedAt, | ||
headers: email.headers, | ||
messageId: email.messageId, | ||
inReplyTo: email.inReplyTo, | ||
references: email.references, | ||
subject: email.subject, | ||
sentAt: email.sentAt, | ||
hasAttachment: email.hasAttachment, | ||
preview: email.preview, | ||
sender: email.sender, | ||
from: email.from, | ||
to: email.to, | ||
cc: email.cc, | ||
bcc: email.bcc, | ||
replyTo: email.replyTo, | ||
textBody: email.textBody, | ||
htmlBody: email.htmlBody, | ||
attachments: email.attachments, | ||
bodyStructure: email.bodyStructure, | ||
bodyValues: email.bodyValues, | ||
headerUserAgent: email.headerUserAgent, | ||
headerMdn: email.headerMdn, | ||
headerCalendarEvent: email.headerCalendarEvent, | ||
sMimeStatusHeader: email.sMimeStatusHeader, | ||
identityHeader: email.identityHeader, | ||
searchSnippetSubject: searchSnippetSubject, | ||
searchSnippetPreview: searchSnippetPreview, | ||
); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
lib/features/thread/domain/model/search_emails_response.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:jmap_dart_client/jmap/mail/email/search_snippet/search_snippet.dart'; | ||
import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart'; | ||
import 'package:tmail_ui_user/features/thread/domain/model/search_email.dart'; | ||
|
||
class SearchEmailsResponse extends EmailsResponse { | ||
const SearchEmailsResponse({ | ||
super.emailList, | ||
super.state, | ||
required this.searchSnippets, | ||
}); | ||
|
||
final List<SearchSnippet>? searchSnippets; | ||
|
||
@override | ||
List<Object?> get props => [...super.props, searchSnippets]; | ||
|
||
List<SearchEmail>? get toSearchEmails { | ||
if (searchSnippets == null) { | ||
return emailList?.map(SearchEmail.fromEmail).toList(); | ||
} | ||
|
||
final mapSearchSnippet = Map.fromEntries( | ||
searchSnippets!.map((searchSnippet) => MapEntry( | ||
searchSnippet.emailId, | ||
searchSnippet))); | ||
|
||
return emailList?.map((email) { | ||
final searchSnippet = mapSearchSnippet[email.id]; | ||
return SearchEmail.fromEmail( | ||
email, | ||
searchSnippetSubject: searchSnippet?.subject, | ||
searchSnippetPreview: searchSnippet?.preview); | ||
}).toList(); | ||
} | ||
} |
Oops, something went wrong.