TF-1857 Add headerCalendarEvent to email cached
(cherry picked from commit 6d884bb6db5365c6308404fb5d98fd356be4109e)
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
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/individual_header_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/model/email_cleanup_rule.dart';
|
||||
@@ -31,6 +32,9 @@ extension EmailCacheExtension on EmailCache {
|
||||
mailboxIds: mailboxIds != null
|
||||
? Map.fromIterables(mailboxIds!.keys.map((value) => MailboxId(Id(value))), mailboxIds!.values)
|
||||
: null,
|
||||
headerCalendarEvent: headerCalendarEvent != null
|
||||
? Map.fromIterables(headerCalendarEvent!.keys.map((value) => IndividualHeaderIdentifier(value)), headerCalendarEvent!.values)
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/extensions/map_header_identifier_id_extension.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/model/email_cache.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/extensions/map_keywords_extension.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/extensions/email_address_extension.dart';
|
||||
@@ -23,6 +24,7 @@ extension EmailExtension on Email {
|
||||
bcc: bcc?.map((emailAddress) => emailAddress.toEmailAddressHiveCache()).toList(),
|
||||
replyTo: replyTo?.map((emailAddress) => emailAddress.toEmailAddressHiveCache()).toList(),
|
||||
mailboxIds: mailboxIds?.toMapString(),
|
||||
headerCalendarEvent: headerCalendarEvent?.toMapString(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/mail/email/individual_header_identifier.dart';
|
||||
|
||||
extension MapHeaderIdentifierExtension on Map<IndividualHeaderIdentifier, String?> {
|
||||
|
||||
Map<String, String?> toMapString() => Map.fromIterables(keys.map((identifier) => identifier.value), values);
|
||||
}
|
||||
@@ -51,6 +51,9 @@ class EmailCache extends HiveObject with EquatableMixin {
|
||||
@HiveField(13)
|
||||
Map<String, bool>? mailboxIds;
|
||||
|
||||
@HiveField(14)
|
||||
Map<String, String?>? headerCalendarEvent;
|
||||
|
||||
EmailCache(
|
||||
this.id,
|
||||
{
|
||||
@@ -67,6 +70,7 @@ class EmailCache extends HiveObject with EquatableMixin {
|
||||
this.bcc,
|
||||
this.replyTo,
|
||||
this.mailboxIds,
|
||||
this.headerCalendarEvent,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -86,5 +90,6 @@ class EmailCache extends HiveObject with EquatableMixin {
|
||||
preview,
|
||||
hasAttachment,
|
||||
mailboxIds,
|
||||
headerCalendarEvent,
|
||||
];
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/individual_header_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/model.dart';
|
||||
@@ -38,24 +39,25 @@ extension EmailExtension on Email {
|
||||
|
||||
Email updatedEmail({Map<KeyWordIdentifier, bool>? newKeywords, Map<MailboxId, bool>? newMailboxIds}) {
|
||||
return Email(
|
||||
id: id,
|
||||
keywords: newKeywords ?? keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
hasAttachment: hasAttachment,
|
||||
preview: preview,
|
||||
subject: subject,
|
||||
sentAt: sentAt,
|
||||
from: from,
|
||||
to: to,
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo,
|
||||
mailboxIds: newMailboxIds ?? mailboxIds,
|
||||
htmlBody: htmlBody,
|
||||
bodyValues: bodyValues,
|
||||
headerUserAgent: headerUserAgent,
|
||||
attachments: attachments
|
||||
id: id,
|
||||
keywords: newKeywords ?? keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
hasAttachment: hasAttachment,
|
||||
preview: preview,
|
||||
subject: subject,
|
||||
sentAt: sentAt,
|
||||
from: from,
|
||||
to: to,
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo,
|
||||
mailboxIds: newMailboxIds ?? mailboxIds,
|
||||
htmlBody: htmlBody,
|
||||
bodyValues: bodyValues,
|
||||
headerUserAgent: headerUserAgent,
|
||||
attachments: attachments,
|
||||
headerCalendarEvent: headerCalendarEvent
|
||||
);
|
||||
}
|
||||
|
||||
@@ -97,6 +99,7 @@ extension EmailExtension on Email {
|
||||
bcc: updatedProperties.contain(EmailProperty.bcc) ? newEmail.bcc : bcc,
|
||||
replyTo: updatedProperties.contain(EmailProperty.replyTo) ? newEmail.replyTo : replyTo,
|
||||
mailboxIds: updatedProperties.contain(EmailProperty.mailboxIds) ? newEmail.mailboxIds : mailboxIds,
|
||||
headerCalendarEvent: updatedProperties.contain(IndividualHeaderIdentifier.headerCalendarEvent.value) ? newEmail.headerCalendarEvent : headerCalendarEvent,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,9 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
replyTo: replyTo,
|
||||
htmlBody: htmlBody,
|
||||
bodyValues: bodyValues,
|
||||
mailboxIds: mailboxIds,
|
||||
headers: emailHeader?.toSet(),
|
||||
headerCalendarEvent: headerCalendarEvent
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user