TF-1626 Remove id of email when call Email/set method
(cherry picked from commit ce1d27d893fd406aa812d4e4ea9debe1ec265ddb)
This commit is contained in:
@@ -638,11 +638,9 @@ class ComposerController extends BaseController {
|
||||
mapKeywords[KeyWordIdentifier.emailSeen] = true;
|
||||
}
|
||||
|
||||
final generateEmailId = EmailId(Id(_uuid.v1()));
|
||||
final generatePartId = PartId(_uuid.v1());
|
||||
|
||||
return Email(
|
||||
generateEmailId,
|
||||
mailboxIds: mailboxIds.isNotEmpty ? mailboxIds : null,
|
||||
from: listFromEmailAddress,
|
||||
to: listToEmailAddress.toSet(),
|
||||
@@ -988,12 +986,16 @@ class ComposerController extends BaseController {
|
||||
draftMailboxId: draftMailboxId);
|
||||
final oldEmail = arguments.presentationEmail;
|
||||
|
||||
if (arguments.emailActionType == EmailActionType.edit && oldEmail != null) {
|
||||
if (arguments.emailActionType == EmailActionType.edit && oldEmail != null && oldEmail.id != null) {
|
||||
mailboxDashBoardController.consumeState(
|
||||
_updateEmailDraftsInteractor.execute(accountId, newEmail, oldEmail.id));
|
||||
_updateEmailDraftsInteractor.execute(
|
||||
accountId,
|
||||
newEmail,
|
||||
oldEmail.id!
|
||||
)
|
||||
);
|
||||
} else {
|
||||
mailboxDashBoardController.consumeState(
|
||||
_saveEmailAsDraftsInteractor.execute(accountId, newEmail));
|
||||
mailboxDashBoardController.consumeState(_saveEmailAsDraftsInteractor.execute(accountId, newEmail));
|
||||
}
|
||||
|
||||
uploadController.clearInlineFileUploaded();
|
||||
|
||||
@@ -41,6 +41,7 @@ import 'package:model/email/mark_star_action.dart';
|
||||
import 'package:model/email/read_actions.dart';
|
||||
import 'package:model/extensions/email_extension.dart';
|
||||
import 'package:model/extensions/keyword_identifier_extension.dart';
|
||||
import 'package:model/extensions/list_email_extension.dart';
|
||||
import 'package:model/extensions/list_email_id_extension.dart';
|
||||
import 'package:model/extensions/mailbox_id_extension.dart';
|
||||
import 'package:model/extensions/session_extension.dart';
|
||||
@@ -54,14 +55,16 @@ import 'package:tmail_ui_user/features/email/domain/state/download_attachment_fo
|
||||
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/create_new_mailbox_request.dart';
|
||||
import 'package:tmail_ui_user/main/error/capability_validator.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class EmailAPI with HandleSetErrorMixin {
|
||||
|
||||
final HttpClient _httpClient;
|
||||
final DownloadManager _downloadManager;
|
||||
final DioClient _dioClient;
|
||||
final Uuid _uuid;
|
||||
|
||||
EmailAPI(this._httpClient, this._downloadManager, this._dioClient);
|
||||
EmailAPI(this._httpClient, this._downloadManager, this._dioClient, this._uuid);
|
||||
|
||||
Future<Email> getEmailContent(AccountId accountId, EmailId emailId) async {
|
||||
final processingInvocation = ProcessingInvocation();
|
||||
@@ -129,8 +132,9 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
emailNeedsToBeCreated = emailRequest.email;
|
||||
}
|
||||
|
||||
final idCreateMethod = Id(_uuid.v1());
|
||||
final setEmailMethod = SetEmailMethod(accountId)
|
||||
..addCreate(emailNeedsToBeCreated.id.id, emailNeedsToBeCreated);
|
||||
..addCreate(idCreateMethod, emailNeedsToBeCreated);
|
||||
|
||||
if (emailRequest.emailIdDestroyed != null) {
|
||||
setEmailMethod.addDestroy({emailRequest.emailIdDestroyed!.id});
|
||||
@@ -142,7 +146,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
emailRequest.submissionCreateId,
|
||||
EmailSubmission(
|
||||
identityId: emailRequest.identity?.id?.id,
|
||||
emailId: EmailId(ReferenceId(ReferencePrefix.defaultPrefix, emailNeedsToBeCreated.id.id)),
|
||||
emailId: EmailId(ReferenceId(ReferencePrefix.defaultPrefix, idCreateMethod)),
|
||||
envelope: Envelope(
|
||||
Address(emailNeedsToBeCreated.from?.first.email ?? ''),
|
||||
emailNeedsToBeCreated.getRecipientEmailAddressList().map((emailAddress) => Address(emailAddress)).toSet()
|
||||
@@ -173,7 +177,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
SetEmailSubmissionResponse.deserialize,
|
||||
methodName: setEmailInvocation.methodName);
|
||||
|
||||
final emailCreated = setEmailResponse?.created?[emailNeedsToBeCreated.id.id];
|
||||
final emailCreated = setEmailResponse?.created?[idCreateMethod];
|
||||
final listEntriesErrors = _handleSetEmailResponse(
|
||||
response: setEmailResponse,
|
||||
submissionResponse: setEmailSubmissionResponse
|
||||
@@ -218,13 +222,11 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
}
|
||||
|
||||
Future<List<Email>> markAsRead(AccountId accountId, List<Email> emails, ReadActions readActions) async {
|
||||
final emailIds = emails.map((email) => email.id).toList();
|
||||
|
||||
final setEmailMethod = SetEmailMethod(accountId)
|
||||
..addUpdates(emailIds.generateMapUpdateObjectMarkAsRead(readActions));
|
||||
..addUpdates(emails.listEmailIds.generateMapUpdateObjectMarkAsRead(readActions));
|
||||
|
||||
final getEmailMethod = GetEmailMethod(accountId)
|
||||
..addIds(emailIds.toIds().toSet())
|
||||
..addIds(emails.listEmailIds.toIds().toSet())
|
||||
..addProperties(Properties({'keywords'}));
|
||||
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
@@ -406,13 +408,11 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
|
||||
|
||||
Future<List<Email>> markAsStar(AccountId accountId, List<Email> emails, MarkStarAction markStarAction) async {
|
||||
final emailIds = emails.map((email) => email.id).toList();
|
||||
|
||||
final setEmailMethod = SetEmailMethod(accountId)
|
||||
..addUpdates(emailIds.generateMapUpdateObjectMarkAsStar(markStarAction));
|
||||
..addUpdates(emails.listEmailIds.generateMapUpdateObjectMarkAsStar(markStarAction));
|
||||
|
||||
final getEmailMethod = GetEmailMethod(accountId)
|
||||
..addIds(emailIds.toIds().toSet())
|
||||
..addIds(emails.listEmailIds.toIds().toSet())
|
||||
..addProperties(Properties({'keywords'}));
|
||||
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
@@ -438,8 +438,9 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
}
|
||||
|
||||
Future<Email> saveEmailAsDrafts(AccountId accountId, Email email) async {
|
||||
final idCreateMethod = Id(_uuid.v1());
|
||||
final setEmailMethod = SetEmailMethod(accountId)
|
||||
..addCreate(email.id.id, email);
|
||||
..addCreate(idCreateMethod, email);
|
||||
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
|
||||
@@ -455,7 +456,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
SetEmailResponse.deserialize
|
||||
);
|
||||
|
||||
final emailCreated = setEmailResponse?.created?[email.id.id];
|
||||
final emailCreated = setEmailResponse?.created?[idCreateMethod];
|
||||
final listEntriesErrors = _handleSetEmailResponse(response: setEmailResponse);
|
||||
final mapErrors = Map.fromEntries(listEntriesErrors);
|
||||
|
||||
@@ -491,8 +492,9 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
}
|
||||
|
||||
Future<Email> updateEmailDrafts(AccountId accountId, Email newEmail, EmailId oldEmailId) async {
|
||||
final idCreateMethod = Id(_uuid.v1());
|
||||
final setEmailMethod = SetEmailMethod(accountId)
|
||||
..addCreate(newEmail.id.id, newEmail)
|
||||
..addCreate(idCreateMethod, newEmail)
|
||||
..addDestroy({oldEmailId.id});
|
||||
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
@@ -509,7 +511,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
SetEmailResponse.deserialize
|
||||
);
|
||||
|
||||
final emailUpdated = setEmailResponse?.created?[newEmail.id.id];
|
||||
final emailUpdated = setEmailResponse?.created?[idCreateMethod];
|
||||
final isEmailDestroyedSuccess = setEmailResponse?.destroyed?.contains(oldEmailId.id) ?? false;
|
||||
final listEntriesErrors = _handleSetEmailResponse(response: setEmailResponse);
|
||||
final mapErrors = Map.fromEntries(listEntriesErrors);
|
||||
|
||||
@@ -170,9 +170,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
_resetToOriginalValue();
|
||||
|
||||
if (isListEmailContainSelectedEmail(selectedEmail)) {
|
||||
_createMultipleEmailViewAsPageView(selectedEmail.id);
|
||||
_createMultipleEmailViewAsPageView(selectedEmail.id!);
|
||||
} else {
|
||||
_createSingleEmailView(selectedEmail.id);
|
||||
_createSingleEmailView(selectedEmail.id!);
|
||||
}
|
||||
|
||||
if (!selectedEmail.hasRead) {
|
||||
@@ -663,21 +663,21 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
) {
|
||||
if (destinationMailbox.isTrash) {
|
||||
_moveToTrashAction(context, accountId, MoveToMailboxRequest(
|
||||
{currentMailbox.id: [emailSelected.id]},
|
||||
{currentMailbox.id: [emailSelected.id!]},
|
||||
destinationMailbox.id,
|
||||
MoveAction.moving,
|
||||
session,
|
||||
EmailActionType.moveToTrash));
|
||||
} else if (destinationMailbox.isSpam) {
|
||||
_moveToSpamAction(context, accountId, MoveToMailboxRequest(
|
||||
{currentMailbox.id: [emailSelected.id]},
|
||||
{currentMailbox.id: [emailSelected.id!]},
|
||||
destinationMailbox.id,
|
||||
MoveAction.moving,
|
||||
session,
|
||||
EmailActionType.moveToSpam));
|
||||
} else {
|
||||
_moveToMailbox(context, accountId, MoveToMailboxRequest(
|
||||
{currentMailbox.id: [emailSelected.id]},
|
||||
{currentMailbox.id: [emailSelected.id!]},
|
||||
destinationMailbox.id,
|
||||
MoveAction.moving,
|
||||
session,
|
||||
@@ -729,7 +729,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
if (accountId != null && currentMailbox != null && trashMailboxId != null) {
|
||||
_moveToTrashAction(context, accountId, MoveToMailboxRequest(
|
||||
{currentMailbox.id: [email.id]},
|
||||
{currentMailbox.id: [email.id!]},
|
||||
trashMailboxId,
|
||||
MoveAction.moving,
|
||||
mailboxDashBoardController.sessionCurrent!,
|
||||
@@ -750,7 +750,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
if (accountId != null && currentMailbox != null && spamMailboxId != null) {
|
||||
_moveToSpamAction(context, accountId, MoveToMailboxRequest(
|
||||
{currentMailbox.id: [email.id]},
|
||||
{currentMailbox.id: [email.id!]},
|
||||
spamMailboxId,
|
||||
MoveAction.moving,
|
||||
mailboxDashBoardController.sessionCurrent!,
|
||||
@@ -766,7 +766,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
if (accountId != null && spamMailboxId != null && inboxMailboxId != null) {
|
||||
_moveToSpamAction(context, accountId, MoveToMailboxRequest(
|
||||
{spamMailboxId: [email.id]},
|
||||
{spamMailboxId: [email.id!]},
|
||||
inboxMailboxId,
|
||||
MoveAction.moving,
|
||||
mailboxDashBoardController.sessionCurrent!,
|
||||
|
||||
+12
-13
@@ -235,7 +235,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
final ComposerArguments composerArguments = ComposerArguments(
|
||||
emailActionType: EmailActionType.edit,
|
||||
presentationEmail: PresentationEmail(
|
||||
success.composerCache.id,
|
||||
id: success.composerCache.id,
|
||||
subject: success.composerCache.subject,
|
||||
from: success.composerCache.from,
|
||||
to: success.composerCache.to,
|
||||
@@ -519,7 +519,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
dispatchRoute(DashboardRoutes.emailDetailed);
|
||||
if (BuildUtils.isWeb && presentationEmail.routeWeb != null) {
|
||||
RouteUtils.updateRouteOnBrowser(
|
||||
'Email-${presentationEmail.id.id.value}',
|
||||
'Email-${presentationEmail.id?.id.value ?? ''}',
|
||||
presentationEmail.routeWeb!
|
||||
);
|
||||
}
|
||||
@@ -628,15 +628,15 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
|
||||
void _discardEmail(Email email) {
|
||||
final currentAccountId = accountId.value;
|
||||
if (currentAccountId != null) {
|
||||
consumeState(_removeEmailDraftsInteractor.execute(currentAccountId, email.id));
|
||||
if (currentAccountId != null && email.id != null) {
|
||||
consumeState(_removeEmailDraftsInteractor.execute(currentAccountId, email.id!));
|
||||
}
|
||||
}
|
||||
|
||||
void deleteEmailPermanently(PresentationEmail email) {
|
||||
final currentAccountId = accountId.value;
|
||||
if (currentAccountId != null) {
|
||||
consumeState(_deleteEmailPermanentlyInteractor.execute(currentAccountId, email.id));
|
||||
if (currentAccountId != null && email.id != null) {
|
||||
consumeState(_deleteEmailPermanentlyInteractor.execute(currentAccountId, email.id!));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,22 +825,21 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
List<PresentationEmail> listEmails,
|
||||
PresentationMailbox destinationMailbox,
|
||||
) {
|
||||
if(searchController.isSearchEmailRunning){
|
||||
if (searchController.isSearchEmailRunning){
|
||||
final Map<MailboxId,List<EmailId>> mapListEmailSelectedByMailBoxId = {};
|
||||
for (var element in listEmails) {
|
||||
final mailbox = element.findMailboxContain(mapMailboxById);
|
||||
if(mailbox != null) {
|
||||
if(mapListEmailSelectedByMailBoxId.containsKey(mailbox.id)) {
|
||||
mapListEmailSelectedByMailBoxId[mailbox.id]?.add(element.id);
|
||||
if (mailbox != null && element.id != null) {
|
||||
if (mapListEmailSelectedByMailBoxId.containsKey(mailbox.id)) {
|
||||
mapListEmailSelectedByMailBoxId[mailbox.id]?.add(element.id!);
|
||||
} else {
|
||||
mapListEmailSelectedByMailBoxId.addAll({mailbox.id: [element.id]});
|
||||
mapListEmailSelectedByMailBoxId.addAll({mailbox.id: [element.id!]});
|
||||
}
|
||||
}
|
||||
}
|
||||
_handleDragSelectedMultipleEmailToMailboxAction(mapListEmailSelectedByMailBoxId, destinationMailbox);
|
||||
|
||||
} else {
|
||||
if(selectedMailbox.value != null) {
|
||||
if (selectedMailbox.value != null) {
|
||||
_handleDragSelectedMultipleEmailToMailboxAction({selectedMailbox.value!.id: listEmails.listEmailIds}, destinationMailbox);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class EmailChangeListener extends ChangeListener {
|
||||
final notificationPayload = NotificationPayload(emailId: presentationEmail.id);
|
||||
log('EmailChangeListener::_showLocalNotification():notificationPayload: $notificationPayload');
|
||||
LocalNotificationManager.instance.showPushNotification(
|
||||
id: presentationEmail.id.id.value,
|
||||
id: presentationEmail.id?.id.value ?? '',
|
||||
title: presentationEmail.subject ?? '',
|
||||
message: presentationEmail.preview,
|
||||
emailAddress: presentationEmail.from?.first,
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'package:tmail_ui_user/features/thread/data/extensions/email_address_hive
|
||||
extension EmailCacheExtension on EmailCache {
|
||||
Email toEmail() {
|
||||
return Email(
|
||||
EmailId(Id(id)),
|
||||
id: EmailId(Id(id)),
|
||||
keywords: keywords != null
|
||||
? Map.fromIterables(keywords!.keys.map((value) => KeyWordIdentifier(value)), keywords!.values)
|
||||
: null,
|
||||
|
||||
@@ -8,7 +8,7 @@ extension EmailExtension on Email {
|
||||
|
||||
EmailCache toEmailCache() {
|
||||
return EmailCache(
|
||||
id.id.value,
|
||||
id!.id.value,
|
||||
keywords: keywords?.toMapString(),
|
||||
size: size?.value.round(),
|
||||
receivedAt: receivedAt?.value,
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'package:jmap_dart_client/jmap/mail/email/email_comparator_property.dart'
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_filter_condition.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/email/email_property.dart';
|
||||
import 'package:model/extensions/list_email_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/data/network/email_api.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/model/empty_trash_folder_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_api.dart';
|
||||
@@ -68,11 +69,9 @@ class ThreadIsolateWorker {
|
||||
if (newEmailList.isNotEmpty) {
|
||||
lastEmail = newEmailList.last;
|
||||
hasEmails = true;
|
||||
final emailIds = newEmailList.map((email) => email.id).toList();
|
||||
final listEmailIdDeleted = await args.emailAPI.deleteMultipleEmailsPermanently(args.accountId, newEmailList.listEmailIds);
|
||||
|
||||
final listEmailIdDeleted = await args.emailAPI.deleteMultipleEmailsPermanently(args.accountId, emailIds);
|
||||
|
||||
if (listEmailIdDeleted.isNotEmpty && listEmailIdDeleted.length == emailIds.length) {
|
||||
if (listEmailIdDeleted.isNotEmpty && listEmailIdDeleted.length == newEmailList.listEmailIds.length) {
|
||||
sendPort.send(listEmailIdDeleted);
|
||||
}
|
||||
emailListCompleted.addAll(listEmailIdDeleted);
|
||||
@@ -117,11 +116,9 @@ class ThreadIsolateWorker {
|
||||
if (newEmailList.isNotEmpty) {
|
||||
lastEmail = newEmailList.last;
|
||||
hasEmails = true;
|
||||
final emailIds = newEmailList.map((email) => email.id).toList();
|
||||
final listEmailIdDeleted = await _emailAPI.deleteMultipleEmailsPermanently(accountId, newEmailList.listEmailIds);
|
||||
|
||||
final listEmailIdDeleted = await _emailAPI.deleteMultipleEmailsPermanently(accountId, emailIds);
|
||||
|
||||
if (listEmailIdDeleted.isNotEmpty && listEmailIdDeleted.length == emailIds.length) {
|
||||
if (listEmailIdDeleted.isNotEmpty && listEmailIdDeleted.length == newEmailList.listEmailIds.length) {
|
||||
await updateDestroyedEmailCache(listEmailIdDeleted);
|
||||
}
|
||||
emailListCompleted.addAll(listEmailIdDeleted);
|
||||
|
||||
@@ -157,7 +157,9 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
}
|
||||
|
||||
dartz.Tuple2<Email, Email?> _combineUpdatedWithEmailInCache(Email updatedEmail, List<Email>? emailCacheList) {
|
||||
final emailOld = emailCacheList?.findEmailById(updatedEmail.id);
|
||||
final emailOld = updatedEmail.id != null
|
||||
? emailCacheList?.findEmailById(updatedEmail.id!)
|
||||
: null;
|
||||
if (emailOld != null) {
|
||||
log('ThreadRepositoryImpl::_combineUpdatedWithEmailInCache(): cache hit');
|
||||
return dartz.Tuple2(updatedEmail, emailOld);
|
||||
|
||||
@@ -56,7 +56,7 @@ mixin EmailActionController on ViewAsDialogActionMixin {
|
||||
|
||||
if (mailboxContain != null && accountId != null && trashMailboxId != null) {
|
||||
_moveToTrashAction(accountId, MoveToMailboxRequest(
|
||||
{mailboxContain.id: [email.id]},
|
||||
{mailboxContain.id: email.id != null ? [email.id!] : []},
|
||||
trashMailboxId,
|
||||
MoveAction.moving,
|
||||
mailboxDashBoardController.sessionCurrent!,
|
||||
@@ -75,7 +75,7 @@ mixin EmailActionController on ViewAsDialogActionMixin {
|
||||
|
||||
if (mailboxContain != null && accountId != null && spamMailboxId != null) {
|
||||
moveToSpamAction(accountId, MoveToMailboxRequest(
|
||||
{mailboxContain.id: [email.id]},
|
||||
{mailboxContain.id: email.id != null ? [email.id!] : []},
|
||||
spamMailboxId,
|
||||
MoveAction.moving,
|
||||
mailboxDashBoardController.sessionCurrent!,
|
||||
@@ -91,7 +91,7 @@ mixin EmailActionController on ViewAsDialogActionMixin {
|
||||
|
||||
if (inboxMailboxId != null && accountId != null && spamMailboxId != null) {
|
||||
moveToSpamAction(accountId, MoveToMailboxRequest(
|
||||
{spamMailboxId: [email.id]},
|
||||
{spamMailboxId: email.id != null ? [email.id!] : []},
|
||||
inboxMailboxId,
|
||||
MoveAction.moving,
|
||||
mailboxDashBoardController.sessionCurrent!,
|
||||
@@ -161,21 +161,21 @@ mixin EmailActionController on ViewAsDialogActionMixin {
|
||||
) {
|
||||
if (destinationMailbox.isTrash) {
|
||||
moveToSpamAction(accountId, MoveToMailboxRequest(
|
||||
{currentMailbox.id: [emailSelected.id]},
|
||||
{currentMailbox.id: emailSelected.id != null ? [emailSelected.id!] : []},
|
||||
destinationMailbox.id,
|
||||
MoveAction.moving,
|
||||
session,
|
||||
EmailActionType.moveToTrash));
|
||||
} else if (destinationMailbox.isSpam) {
|
||||
moveToSpamAction(accountId, MoveToMailboxRequest(
|
||||
{currentMailbox.id: [emailSelected.id]},
|
||||
{currentMailbox.id: emailSelected.id != null ? [emailSelected.id!] : []},
|
||||
destinationMailbox.id,
|
||||
MoveAction.moving,
|
||||
session,
|
||||
EmailActionType.moveToSpam));
|
||||
} else {
|
||||
_moveToMailboxAction(accountId, MoveToMailboxRequest(
|
||||
{currentMailbox.id: [emailSelected.id]},
|
||||
{currentMailbox.id: emailSelected.id != null ? [emailSelected.id!] : []},
|
||||
destinationMailbox.id,
|
||||
MoveAction.moving,
|
||||
session,
|
||||
|
||||
@@ -887,8 +887,8 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
}
|
||||
|
||||
void calculateDragValue(PresentationEmail? currentPresentationEmail) {
|
||||
if(currentPresentationEmail != null) {
|
||||
if(mailboxDashBoardController.listEmailSelected.findEmail(currentPresentationEmail.id) != null){
|
||||
if (currentPresentationEmail != null) {
|
||||
if (currentPresentationEmail.id != null && mailboxDashBoardController.listEmailSelected.findEmail(currentPresentationEmail.id!) != null){
|
||||
listEmailDrag.clear();
|
||||
listEmailDrag.addAll(mailboxDashBoardController.listEmailSelected);
|
||||
} else {
|
||||
|
||||
@@ -27,6 +27,7 @@ import 'package:tmail_ui_user/features/quotas/data/network/quotas_api.dart';
|
||||
import 'package:tmail_ui_user/features/session/data/network/session_api.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_api.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class NetworkBindings extends Bindings {
|
||||
|
||||
@@ -82,7 +83,9 @@ class NetworkBindings extends Bindings {
|
||||
Get.put(EmailAPI(
|
||||
Get.find<HttpClient>(),
|
||||
Get.find<DownloadManager>(),
|
||||
Get.find<DioClient>()));
|
||||
Get.find<DioClient>(),
|
||||
Get.find<Uuid>(),
|
||||
));
|
||||
Get.put(RuleFilterAPI(Get.find<HttpClient>()));
|
||||
Get.put(VacationAPI(Get.find<HttpClient>()));
|
||||
Get.put(ContactAPI(Get.find<HttpClient>()));
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_isolate_work
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_api.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_isolate_worker.dart';
|
||||
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:worker_manager/worker_manager.dart';
|
||||
|
||||
class NetworkIsolateBindings extends Bindings {
|
||||
@@ -51,7 +52,9 @@ class NetworkIsolateBindings extends Bindings {
|
||||
Get.put(EmailAPI(
|
||||
httpClient,
|
||||
Get.find<DownloadManager>(tag: BindingTag.isolateTag),
|
||||
Get.find<DioClient>(tag: BindingTag.isolateTag)), tag: BindingTag.isolateTag);
|
||||
Get.find<DioClient>(tag: BindingTag.isolateTag),
|
||||
Get.find<Uuid>()
|
||||
), tag: BindingTag.isolateTag);
|
||||
}
|
||||
|
||||
void _bindingIsolateWorker() {
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'package:model/mailbox/select_mode.dart';
|
||||
|
||||
class PresentationEmail with EquatableMixin {
|
||||
|
||||
final EmailId id;
|
||||
final EmailId? id;
|
||||
final Map<KeyWordIdentifier, bool>? keywords;
|
||||
final UnsignedInt? size;
|
||||
final UTCDate? receivedAt;
|
||||
@@ -32,28 +32,26 @@ class PresentationEmail with EquatableMixin {
|
||||
final Uri? routeWeb;
|
||||
final PresentationMailbox? mailboxContain;
|
||||
|
||||
PresentationEmail(
|
||||
PresentationEmail({
|
||||
this.id,
|
||||
{
|
||||
this.keywords,
|
||||
this.size,
|
||||
this.receivedAt,
|
||||
this.hasAttachment,
|
||||
this.preview,
|
||||
this.subject,
|
||||
this.sentAt,
|
||||
this.from,
|
||||
this.to,
|
||||
this.cc,
|
||||
this.bcc,
|
||||
this.replyTo,
|
||||
this.mailboxIds,
|
||||
this.mailboxNames,
|
||||
this.selectMode = SelectMode.INACTIVE,
|
||||
this.routeWeb,
|
||||
this.mailboxContain
|
||||
}
|
||||
);
|
||||
this.keywords,
|
||||
this.size,
|
||||
this.receivedAt,
|
||||
this.hasAttachment,
|
||||
this.preview,
|
||||
this.subject,
|
||||
this.sentAt,
|
||||
this.from,
|
||||
this.to,
|
||||
this.cc,
|
||||
this.bcc,
|
||||
this.replyTo,
|
||||
this.mailboxIds,
|
||||
this.mailboxNames,
|
||||
this.selectMode = SelectMode.INACTIVE,
|
||||
this.routeWeb,
|
||||
this.mailboxContain
|
||||
});
|
||||
|
||||
String getSenderName() {
|
||||
if (from?.isNotEmpty == true) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Vendored
+5
-5
@@ -8,7 +8,7 @@ import 'mailbox_fixtures.dart';
|
||||
|
||||
class EmailFixtures {
|
||||
static final email1 = Email(
|
||||
EmailId(Id("382312d0-fa5c-11eb-b647-2fef1ee78d9e")),
|
||||
id: EmailId(Id("382312d0-fa5c-11eb-b647-2fef1ee78d9e")),
|
||||
preview: "Dear QA,I attached image here",
|
||||
hasAttachment: false,
|
||||
subject: "test inline image",
|
||||
@@ -21,7 +21,7 @@ class EmailFixtures {
|
||||
);
|
||||
|
||||
static final email2 = Email(
|
||||
EmailId(Id("bc8a5320-fa58-11eb-b647-2fef1ee78d9e")),
|
||||
id: EmailId(Id("bc8a5320-fa58-11eb-b647-2fef1ee78d9e")),
|
||||
preview: "This event is about to begin Noti check TimeFriday 23 October 2020 12:00 - 12:30 Europe/Paris (See in Calendar)Location1 thai ha (See in Map)Attendees - User A <usera@qa.open-paas.org> (Organizer) - Lê Nguyễn <userb@qa.open-paas.org> - User C <userc@qa.ope",
|
||||
hasAttachment: false,
|
||||
subject: "Notification: Noti check",
|
||||
@@ -33,7 +33,7 @@ class EmailFixtures {
|
||||
);
|
||||
|
||||
static final email3 = Email(
|
||||
EmailId(Id("ba7e0860-fa58-11eb-b647-2fef1ee78d9e")),
|
||||
id: EmailId(Id("ba7e0860-fa58-11eb-b647-2fef1ee78d9e")),
|
||||
preview: "This event is about to begin Recurrencr TimeWednesday 26 August 2020 05:30 - 06:30 Europe/Paris (See in Calendar)Location1 thai ha (See in Map)Attendees - userb@qa.open-paas.org <userb@qa.open-paas.org> (Organizer) - User A <usera@qa.open-paas.org> Resourc",
|
||||
hasAttachment: false,
|
||||
subject: "Notification: Recurrencr",
|
||||
@@ -46,7 +46,7 @@ class EmailFixtures {
|
||||
);
|
||||
|
||||
static final email4 = Email(
|
||||
EmailId(Id("d9b3b880-fa6f-11eb-b647-2fef1ee78d9e")),
|
||||
id: EmailId(Id("d9b3b880-fa6f-11eb-b647-2fef1ee78d9e")),
|
||||
preview: "alo -- desktop signature",
|
||||
hasAttachment: true,
|
||||
subject: "test attachment",
|
||||
@@ -59,7 +59,7 @@ class EmailFixtures {
|
||||
);
|
||||
|
||||
static final email5 = Email(
|
||||
EmailId(Id("637f1ef0-fa5d-11eb-b647-2fef1ee78d9e")),
|
||||
id: EmailId(Id("637f1ef0-fa5d-11eb-b647-2fef1ee78d9e")),
|
||||
preview: "Dear, test inline Thanks and BRs-- desktop signature",
|
||||
hasAttachment: false,
|
||||
subject: "test inline image",
|
||||
|
||||
Reference in New Issue
Block a user