TF-1626 Remove id of email when call Email/set method
(cherry picked from commit ce1d27d893fd406aa812d4e4ea9debe1ec265ddb)
This commit is contained in:
@@ -34,7 +34,7 @@ extension EmailExtension on Email {
|
||||
|
||||
Email updatedEmail({Map<KeyWordIdentifier, bool>? newKeywords, Map<MailboxId, bool>? newMailboxIds}) {
|
||||
return Email(
|
||||
id,
|
||||
id: id,
|
||||
keywords: newKeywords ?? keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -57,7 +57,7 @@ extension EmailExtension on Email {
|
||||
|
||||
PresentationEmail toPresentationEmail({SelectMode selectMode = SelectMode.INACTIVE}) {
|
||||
return PresentationEmail(
|
||||
id,
|
||||
id: id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -77,7 +77,7 @@ extension EmailExtension on Email {
|
||||
|
||||
Email combineEmail(Email newEmail, Properties updatedProperties) {
|
||||
return Email(
|
||||
newEmail.id,
|
||||
id: newEmail.id,
|
||||
keywords: updatedProperties.contain(EmailProperty.keywords) ? newEmail.keywords : keywords,
|
||||
size: updatedProperties.contain(EmailProperty.size) ? newEmail.size : size,
|
||||
receivedAt: updatedProperties.contain(EmailProperty.receivedAt) ? newEmail.receivedAt : receivedAt,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_comparator_property.dart';
|
||||
@@ -8,6 +9,8 @@ import 'package:jmap_dart_client/jmap/core/extensions/unsigned_int_extension.dar
|
||||
|
||||
extension ListEmailExtension on List<Email> {
|
||||
|
||||
List<EmailId> get listEmailIds => map((email) => email.id).whereNotNull().toList();
|
||||
|
||||
Email? findEmailById(EmailId emailId) {
|
||||
try {
|
||||
return firstWhere((email) => email.id == emailId);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/model.dart';
|
||||
@@ -18,7 +19,7 @@ extension ListPresentationEmailExtension on List<PresentationEmail> {
|
||||
return where((email) => email.selectMode == SelectMode.ACTIVE).toList();
|
||||
}
|
||||
|
||||
List<EmailId> get listEmailIds => map((email) => email.id).toList();
|
||||
List<EmailId> get listEmailIds => map((email) => email.id).whereNotNull().toList();
|
||||
|
||||
bool isAllCanDeletePermanently(Map<MailboxId, PresentationMailbox> mapMailbox) {
|
||||
final listMailboxContain = map((email) => email.findMailboxContain(mapMailbox))
|
||||
@@ -88,9 +89,13 @@ extension ListPresentationEmailExtension on List<PresentationEmail> {
|
||||
|
||||
List<PresentationEmail> combine(List<PresentationEmail> listEmailBefore) {
|
||||
return map((presentationEmail) {
|
||||
final emailBefore = listEmailBefore.findEmail(presentationEmail.id);
|
||||
if (emailBefore != null) {
|
||||
return presentationEmail.toSelectedEmail(selectMode: emailBefore.selectMode);
|
||||
if (presentationEmail.id != null) {
|
||||
final emailBefore = listEmailBefore.findEmail(presentationEmail.id!);
|
||||
if (emailBefore != null) {
|
||||
return presentationEmail.toSelectedEmail(selectMode: emailBefore.selectMode);
|
||||
} else {
|
||||
return presentationEmail;
|
||||
}
|
||||
} else {
|
||||
return presentationEmail;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
PresentationEmail toggleSelect() {
|
||||
return PresentationEmail(
|
||||
this.id,
|
||||
id: this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -58,7 +58,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
PresentationEmail toSelectedEmail({required SelectMode selectMode}) {
|
||||
return PresentationEmail(
|
||||
this.id,
|
||||
id: this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -81,7 +81,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
Email toEmail() {
|
||||
return Email(
|
||||
this.id,
|
||||
id: this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -141,7 +141,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
.toList();
|
||||
|
||||
return PresentationEmail(
|
||||
this.id,
|
||||
id: this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -177,7 +177,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
PresentationEmail withRouteWeb(Uri routeWeb) {
|
||||
return PresentationEmail(
|
||||
this.id,
|
||||
id: this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -200,7 +200,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
PresentationEmail updateKeywords(Map<KeyWordIdentifier, bool>? newKeywords) {
|
||||
return PresentationEmail(
|
||||
this.id,
|
||||
id: this.id,
|
||||
keywords: newKeywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
@@ -223,7 +223,7 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
PresentationEmail syncPresentationEmail({PresentationMailbox? mailboxContain, Uri? routeWeb}) {
|
||||
return PresentationEmail(
|
||||
this.id,
|
||||
id: this.id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
|
||||
Reference in New Issue
Block a user