TF-80 Move multiple email to mailbox from thread view
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension EmailExtension on Email {
|
||||
|
||||
bool isUnReadEmail() => !(keywords?.containsKey(KeyWordIdentifier.emailSeen) == true);
|
||||
|
||||
bool isReadEmail() => keywords?.containsKey(KeyWordIdentifier.emailSeen) == true;
|
||||
|
||||
bool isFlaggedEmail() => keywords?.containsKey(KeyWordIdentifier.emailFlagged) == true;
|
||||
|
||||
Set<String> getRecipientEmailAddressList() {
|
||||
final listEmailAddress = Set<String>();
|
||||
final listToAddress = to.getListAddress() ?? [];
|
||||
@@ -22,6 +29,24 @@ extension EmailExtension on Email {
|
||||
);
|
||||
}
|
||||
|
||||
Email updatedEmail({Map<KeyWordIdentifier, bool>? newKeywords}) {
|
||||
return Email(
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
PresentationEmail toPresentationEmail({SelectMode selectMode = SelectMode.INACTIVE}) {
|
||||
return PresentationEmail(
|
||||
id,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/patch_object.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.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';
|
||||
|
||||
extension ListEmailIdExtension on List<EmailId> {
|
||||
|
||||
List<Id> toIds() => map((emailId) => emailId.id).toList();
|
||||
|
||||
Map<Id, PatchObject> generateMapUpdateObjectMarkAsRead(ReadActions readActions) {
|
||||
final Map<Id, PatchObject> maps = {};
|
||||
forEach((emailId) {
|
||||
maps[emailId.id] = KeyWordIdentifier.emailSeen.generateReadActionPath(readActions);
|
||||
});
|
||||
return maps;
|
||||
}
|
||||
|
||||
Map<Id, PatchObject> generateMapUpdateObjectMoveToMailbox(MailboxId currentMailboxId, MailboxId destinationMailboxId) {
|
||||
final Map<Id, PatchObject> maps = {};
|
||||
forEach((emailId) {
|
||||
maps[emailId.id] = currentMailboxId.generateMoveToMailboxActionPath(destinationMailboxId);
|
||||
});
|
||||
return maps;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension PresentationEmailExtension on PresentationEmail {
|
||||
@@ -14,39 +14,6 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
return '';
|
||||
}
|
||||
|
||||
PresentationEmail markAsReadPresentationEmail(ReadActions readActions) {
|
||||
var newKeyWord = keywords;
|
||||
|
||||
if (readActions == ReadActions.markAsUnread) {
|
||||
newKeyWord?.removeWhere((key, value) => key == KeyWordIdentifier.emailSeen);
|
||||
} else {
|
||||
if (newKeyWord == null) {
|
||||
newKeyWord = {
|
||||
KeyWordIdentifier.emailSeen: true
|
||||
};
|
||||
} else {
|
||||
newKeyWord[KeyWordIdentifier.emailSeen] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return PresentationEmail(
|
||||
id,
|
||||
keywords: newKeyWord,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
hasAttachment: hasAttachment,
|
||||
preview: preview,
|
||||
subject: subject,
|
||||
sentAt: sentAt,
|
||||
from: from,
|
||||
to: to,
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo,
|
||||
selectMode: selectMode
|
||||
);
|
||||
}
|
||||
|
||||
PresentationEmail toggleSelect() {
|
||||
return PresentationEmail(
|
||||
id,
|
||||
@@ -84,4 +51,22 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
selectMode: selectMode
|
||||
);
|
||||
}
|
||||
|
||||
Email toEmail() {
|
||||
return Email(
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension PresentationMailboxExtension on PresentationMailbox {
|
||||
|
||||
PresentationMailbox toPresentationMailbox({required UnsignedInt countUnRead}) {
|
||||
PresentationMailbox toPresentationMailboxWithMailboxPath(String mailboxPath) {
|
||||
return PresentationMailbox(
|
||||
id,
|
||||
name: name,
|
||||
@@ -12,12 +11,29 @@ extension PresentationMailboxExtension on PresentationMailbox {
|
||||
role: role,
|
||||
sortOrder: sortOrder,
|
||||
totalEmails: totalEmails,
|
||||
unreadEmails: UnreadEmails(countUnRead),
|
||||
unreadEmails: unreadEmails,
|
||||
totalThreads: totalThreads,
|
||||
unreadThreads: unreadThreads,
|
||||
myRights: myRights,
|
||||
isSubscribed: isSubscribed,
|
||||
selectMode: selectMode
|
||||
selectMode: selectMode,
|
||||
mailboxPath: mailboxPath
|
||||
);
|
||||
}
|
||||
|
||||
Mailbox toMailbox() {
|
||||
return Mailbox(
|
||||
id,
|
||||
name,
|
||||
parentId,
|
||||
role,
|
||||
sortOrder,
|
||||
totalEmails,
|
||||
unreadEmails,
|
||||
totalThreads,
|
||||
unreadThreads,
|
||||
myRights,
|
||||
isSubscribed
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ class PresentationMailbox with EquatableMixin {
|
||||
final MailboxRights? myRights;
|
||||
final IsSubscribed? isSubscribed;
|
||||
final SelectMode selectMode;
|
||||
final String? mailboxPath;
|
||||
|
||||
PresentationMailbox(
|
||||
this.id,
|
||||
@@ -37,7 +38,8 @@ class PresentationMailbox with EquatableMixin {
|
||||
this.unreadThreads,
|
||||
this.myRights,
|
||||
this.isSubscribed,
|
||||
this.selectMode = SelectMode.INACTIVE
|
||||
this.selectMode = SelectMode.INACTIVE,
|
||||
this.mailboxPath,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ export 'extensions/keyword_identifier_extension.dart';
|
||||
export 'extensions/presentation_mailbox_extension.dart';
|
||||
export 'extensions/email_body_part_extension.dart';
|
||||
export 'extensions/attachment_extension.dart';
|
||||
export 'extensions/list_email_id_extension.dart';
|
||||
export 'extensions/mailbox_id_extension.dart';
|
||||
|
||||
// Download
|
||||
|
||||
Reference in New Issue
Block a user