Skip to content

Commit

Permalink
Revert "TF-2528 Sorting emails by order ids list of Email/query"
Browse files Browse the repository at this point in the history
This reverts commit a566541.
  • Loading branch information
chibenwa committed Feb 6, 2024
1 parent 97f30d9 commit a48ede4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 50 deletions.
5 changes: 1 addition & 4 deletions lib/features/composer/presentation/composer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 0 additions & 20 deletions lib/features/thread/data/extensions/list_email_extension.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -16,23 +15,4 @@ extension ListEmailExtension on List<Email> {
TupleKey(email.id!.asString, accountId.asString, userName.value).encodeKey : email.toEmailCache()
};
}

List<Email> sortingByOrderOfIdList(List<Id> 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;
}
}
34 changes: 8 additions & 26 deletions lib/features/thread/data/network/thread_api.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -75,30 +71,16 @@ class ThreadAPI {
.build()
.execute();

final responseOfGetEmailMethod = result.parse<GetEmailResponse>(
getEmailInvocation.methodCallId,
GetEmailResponse.deserialize);
final resultList = result.parse<GetEmailResponse>(
getEmailInvocation.methodCallId, GetEmailResponse.deserialize);

final responseOfQueryEmailMethod = result.parse<QueryEmailResponse>(
queryEmailInvocation.methodCallId,
QueryEmailResponse.deserialize);

List<Email>? 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<EmailChangeResponse> getChanges(
Expand Down

0 comments on commit a48ede4

Please sign in to comment.