diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index bc94b797ab..b83382a339 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -752,10 +752,7 @@ class ComposerController extends BaseController { type: MediaType.parse('text/html') )}, bodyValues: { - generatePartId: EmailBodyValue( - value: emailBodyText, - isEncodingProblem: false, - isTruncated: false) + generatePartId: EmailBodyValue(emailBodyText, false, false) }, headerUserAgent: {IndividualHeaderIdentifier.headerUserAgent : userAgent}, attachments: attachments.isNotEmpty ? attachments : null, diff --git a/lib/features/thread/data/extensions/list_email_extension.dart b/lib/features/thread/data/extensions/list_email_extension.dart index 77cc18fefe..9640dffee6 100644 --- a/lib/features/thread/data/extensions/list_email_extension.dart +++ b/lib/features/thread/data/extensions/list_email_extension.dart @@ -1,6 +1,5 @@ import 'package:jmap_dart_client/jmap/account_id.dart'; -import 'package:jmap_dart_client/jmap/core/id.dart'; import 'package:jmap_dart_client/jmap/core/user_name.dart'; import 'package:jmap_dart_client/jmap/mail/email/email.dart'; import 'package:model/extensions/account_id_extensions.dart'; @@ -16,23 +15,4 @@ extension ListEmailExtension on List { TupleKey(email.id!.asString, accountId.asString, userName.value).encodeKey : email.toEmailCache() }; } - - List sortingByOrderOfIdList(List ids) { - if (ids.length != length) { - return this; - } - - sort((email1, email2) { - final id1 = email1.id?.id; - final id2 = email2.id?.id; - - if (id1 == null || id2 == null) { - return 0; - } - - final sortIndex = ids.indexOf(id1) - ids.indexOf(id2); - return sortIndex; - }); - return this; - } } \ No newline at end of file diff --git a/lib/features/thread/data/network/thread_api.dart b/lib/features/thread/data/network/thread_api.dart index b2547ad183..93cc0ff5c3 100644 --- a/lib/features/thread/data/network/thread_api.dart +++ b/lib/features/thread/data/network/thread_api.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:core/utils/app_logger.dart'; import 'package:jmap_dart_client/http/http_client.dart'; import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/core/filter/filter.dart'; @@ -17,9 +16,6 @@ import 'package:jmap_dart_client/jmap/mail/email/email.dart'; import 'package:jmap_dart_client/jmap/mail/email/get/get_email_method.dart'; import 'package:jmap_dart_client/jmap/mail/email/get/get_email_response.dart'; import 'package:jmap_dart_client/jmap/mail/email/query/query_email_method.dart'; -import 'package:jmap_dart_client/jmap/mail/email/query/query_email_response.dart'; -import 'package:model/model.dart'; -import 'package:tmail_ui_user/features/thread/data/extensions/list_email_extension.dart'; import 'package:tmail_ui_user/features/thread/data/model/email_change_response.dart'; import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart'; import 'package:tmail_ui_user/main/error/capability_validator.dart'; @@ -75,30 +71,16 @@ class ThreadAPI { .build() .execute(); - final responseOfGetEmailMethod = result.parse( - getEmailInvocation.methodCallId, - GetEmailResponse.deserialize); + final resultList = result.parse( + getEmailInvocation.methodCallId, GetEmailResponse.deserialize); - final responseOfQueryEmailMethod = result.parse( - queryEmailInvocation.methodCallId, - QueryEmailResponse.deserialize); - - List? emailList; - - if (responseOfGetEmailMethod?.list.isNotEmpty == true && - responseOfQueryEmailMethod?.ids.isNotEmpty == true) { - log('ThreadAPI::getAllEmail: QUERY_EMAIL_IDS = ${responseOfQueryEmailMethod?.ids}'); - final listSortedEmail = responseOfGetEmailMethod!.list - .sortingByOrderOfIdList(responseOfQueryEmailMethod!.ids.toList()); - emailList = listSortedEmail; - } else { - emailList = responseOfGetEmailMethod?.list; + if (sort != null && resultList != null) { + for (var comparator in sort) { + resultList.sortEmails(comparator); + } } - log('ThreadAPI::getAllEmail: EMAIL_DISPLAYED_IDS = ${emailList?.listEmailIds}'); - return EmailsResponse( - emailList: emailList, - state: responseOfGetEmailMethod?.state - ); + + return EmailsResponse(emailList: resultList?.list, state: resultList?.state); } Future getChanges(