TF-1604: Add requiredCapabilities support TeamMailbox for GetEmailMethod
(cherry picked from commit 3922303e63a8e910511361019a54ea13801e3f92)
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/filter/filter.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
@@ -15,6 +16,7 @@ import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option
|
||||
|
||||
abstract class ThreadDataSource {
|
||||
Future<EmailsResponse> getAllEmail(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
@@ -25,6 +27,7 @@ abstract class ThreadDataSource {
|
||||
);
|
||||
|
||||
Future<EmailChangeResponse> getChanges(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
State sinceState,
|
||||
{
|
||||
@@ -38,10 +41,11 @@ abstract class ThreadDataSource {
|
||||
Future<void> update({List<Email>? updated, List<Email>? created, List<EmailId>? destroyed});
|
||||
|
||||
Future<List<EmailId>> emptyTrashFolder(
|
||||
AccountId accountId,
|
||||
MailboxId mailboxId,
|
||||
Future<void> Function(List<EmailId>? newDestroyed) updateDestroyedEmailCache,
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
MailboxId mailboxId,
|
||||
Future<void> Function(List<EmailId>? newDestroyed) updateDestroyedEmailCache,
|
||||
);
|
||||
|
||||
Future<PresentationEmail> getEmailById(AccountId accountId, EmailId emailId, {Properties? properties});
|
||||
Future<PresentationEmail> getEmailById(Session session, AccountId accountId, EmailId emailId, {Properties? properties});
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/filter/filter.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
@@ -25,25 +26,27 @@ class LocalThreadDataSourceImpl extends ThreadDataSource {
|
||||
|
||||
@override
|
||||
Future<EmailsResponse> getAllEmail(
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
Set<Comparator>? sort,
|
||||
Filter? filter,
|
||||
Properties? properties
|
||||
}
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
Set<Comparator>? sort,
|
||||
Filter? filter,
|
||||
Properties? properties
|
||||
}
|
||||
) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<EmailChangeResponse> getChanges(
|
||||
AccountId accountId,
|
||||
State sinceState,
|
||||
{
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated
|
||||
}
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
State sinceState,
|
||||
{
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated
|
||||
}
|
||||
) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
@@ -80,6 +83,7 @@ class LocalThreadDataSourceImpl extends ThreadDataSource {
|
||||
|
||||
@override
|
||||
Future<List<EmailId>> emptyTrashFolder(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
MailboxId mailboxId,
|
||||
Future<void> Function(List<EmailId>? newDestroyed) updateDestroyedEmailCache
|
||||
@@ -88,7 +92,7 @@ class LocalThreadDataSourceImpl extends ThreadDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PresentationEmail> getEmailById(AccountId accountId, EmailId emailId, {Properties? properties}) {
|
||||
Future<PresentationEmail> getEmailById(Session session, AccountId accountId, EmailId emailId, {Properties? properties}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/filter/filter.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
@@ -32,6 +33,7 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
|
||||
@override
|
||||
Future<EmailsResponse> getAllEmail(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
@@ -42,6 +44,7 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return await threadAPI.getAllEmail(
|
||||
session,
|
||||
accountId,
|
||||
limit: limit,
|
||||
sort: sort,
|
||||
@@ -52,15 +55,17 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
|
||||
@override
|
||||
Future<EmailChangeResponse> getChanges(
|
||||
AccountId accountId,
|
||||
State sinceState,
|
||||
{
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated
|
||||
}
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
State sinceState,
|
||||
{
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated
|
||||
}
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return await threadAPI.getChanges(
|
||||
session,
|
||||
accountId,
|
||||
sinceState,
|
||||
propertiesCreated: propertiesCreated,
|
||||
@@ -79,20 +84,26 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<EmailId>> emptyTrashFolder(AccountId accountId, MailboxId mailboxId, Future<void> Function(List<EmailId>? newDestroyed) updateDestroyedEmailCache) {
|
||||
Future<List<EmailId>> emptyTrashFolder(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
MailboxId mailboxId,
|
||||
Future<void> Function(List<EmailId>? newDestroyed) updateDestroyedEmailCache
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return await _threadIsolateWorker.emptyTrashFolder(
|
||||
accountId,
|
||||
mailboxId,
|
||||
updateDestroyedEmailCache,
|
||||
session,
|
||||
accountId,
|
||||
mailboxId,
|
||||
updateDestroyedEmailCache,
|
||||
);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PresentationEmail> getEmailById(AccountId accountId, EmailId emailId, {Properties? properties}) {
|
||||
Future<PresentationEmail> getEmailById(Session session, AccountId accountId, EmailId emailId, {Properties? properties}) {
|
||||
return Future.sync(() async {
|
||||
final email = await threadAPI.getEmailById(accountId, emailId, properties: properties);
|
||||
final email = await threadAPI.getEmailById(session, accountId, emailId, properties: properties);
|
||||
return email.toPresentationEmail();
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/email/data/network/email_api.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_api.dart';
|
||||
|
||||
class EmptyTrashFolderArguments with EquatableMixin {
|
||||
final Session session;
|
||||
final AccountId accountId;
|
||||
final MailboxId trashMailboxId;
|
||||
final ThreadAPI threadAPI;
|
||||
final EmailAPI emailAPI;
|
||||
|
||||
EmptyTrashFolderArguments(
|
||||
this.session,
|
||||
this.threadAPI,
|
||||
this.emailAPI,
|
||||
this.accountId,
|
||||
@@ -18,5 +21,11 @@ class EmptyTrashFolderArguments with EquatableMixin {
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [accountId, trashMailboxId];
|
||||
List<Object?> get props => [
|
||||
session,
|
||||
accountId,
|
||||
emailAPI,
|
||||
threadAPI,
|
||||
trashMailboxId
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ import 'dart:async';
|
||||
|
||||
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/capability/capability_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/filter/filter.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/request/reference_path.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
@@ -17,6 +19,7 @@ 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: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';
|
||||
|
||||
class ThreadAPI {
|
||||
|
||||
@@ -24,7 +27,25 @@ class ThreadAPI {
|
||||
|
||||
ThreadAPI(this.httpClient);
|
||||
|
||||
Set<CapabilityIdentifier> _capabilitiesForEmailMethod(Session session, AccountId accountId) {
|
||||
final getMailboxCreated = GetEmailMethod(accountId);
|
||||
try {
|
||||
requireCapability(
|
||||
session,
|
||||
accountId,
|
||||
[CapabilityIdentifier.jmapTeamMailboxes]);
|
||||
return {
|
||||
CapabilityIdentifier.jmapCore,
|
||||
CapabilityIdentifier.jmapMail,
|
||||
CapabilityIdentifier.jmapTeamMailboxes
|
||||
};
|
||||
} catch (_) {
|
||||
return getMailboxCreated.requiredCapabilities;
|
||||
}
|
||||
}
|
||||
|
||||
Future<EmailsResponse> getAllEmail(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
@@ -58,7 +79,7 @@ class ThreadAPI {
|
||||
final getEmailInvocation = jmapRequestBuilder.invocation(getEmailMethod);
|
||||
|
||||
final result = await (jmapRequestBuilder
|
||||
..usings(getEmailMethod.requiredCapabilities))
|
||||
..usings(_capabilitiesForEmailMethod(session, accountId)))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
@@ -75,6 +96,7 @@ class ThreadAPI {
|
||||
}
|
||||
|
||||
Future<EmailChangeResponse> getChanges(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
State sinceState,
|
||||
{
|
||||
@@ -112,7 +134,7 @@ class ThreadAPI {
|
||||
final getEmailCreatedInvocation = jmapRequestBuilder.invocation(getEmailCreated);
|
||||
|
||||
final result = await (jmapRequestBuilder
|
||||
..usings(getEmailCreated.requiredCapabilities))
|
||||
..usings(_capabilitiesForEmailMethod(session, accountId)))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
@@ -140,7 +162,7 @@ class ThreadAPI {
|
||||
updatedProperties: propertiesUpdated);
|
||||
}
|
||||
|
||||
Future<Email> getEmailById(AccountId accountId, EmailId emailId, {Properties? properties}) async {
|
||||
Future<Email> getEmailById(Session session, AccountId accountId, EmailId emailId, {Properties? properties}) async {
|
||||
final processingInvocation = ProcessingInvocation();
|
||||
final jmapRequestBuilder = JmapRequestBuilder(httpClient, processingInvocation);
|
||||
|
||||
@@ -154,7 +176,7 @@ class ThreadAPI {
|
||||
final getEmailInvocation = jmapRequestBuilder.invocation(getEmailMethod);
|
||||
|
||||
final result = await (jmapRequestBuilder
|
||||
..usings(getEmailMethod.requiredCapabilities))
|
||||
..usings(_capabilitiesForEmailMethod(session, accountId)))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/build_utils.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_comparator.dart';
|
||||
@@ -25,15 +26,16 @@ class ThreadIsolateWorker {
|
||||
ThreadIsolateWorker(this._threadAPI, this._emailAPI, this._isolateExecutor);
|
||||
|
||||
Future<List<EmailId>> emptyTrashFolder(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
MailboxId mailboxId,
|
||||
Future<void> Function(List<EmailId>? newDestroyed) updateDestroyedEmailCache,
|
||||
) async {
|
||||
if (BuildUtils.isWeb) {
|
||||
return _emptyTrashFolderOnWeb(accountId, mailboxId, updateDestroyedEmailCache);
|
||||
return _emptyTrashFolderOnWeb(session, accountId, mailboxId, updateDestroyedEmailCache);
|
||||
} else {
|
||||
final result = await _isolateExecutor.execute(
|
||||
arg1: EmptyTrashFolderArguments(_threadAPI, _emailAPI, accountId, mailboxId),
|
||||
arg1: EmptyTrashFolderArguments(session, _threadAPI, _emailAPI, accountId, mailboxId),
|
||||
fun1: _emptyTrashFolderAction,
|
||||
notification: (value) {
|
||||
if (value is List<EmailId>) {
|
||||
@@ -52,12 +54,14 @@ class ThreadIsolateWorker {
|
||||
Email? lastEmail;
|
||||
|
||||
while (hasEmails) {
|
||||
final emailsResponse = await args.threadAPI.getAllEmail(args.accountId,
|
||||
sort: <Comparator>{}..add(
|
||||
EmailComparator(EmailComparatorProperty.receivedAt)
|
||||
..setIsAscending(false)),
|
||||
filter: EmailFilterCondition(inMailbox: args.trashMailboxId, before: lastEmail?.receivedAt),
|
||||
properties: Properties({EmailProperty.id}));
|
||||
final emailsResponse = await args.threadAPI.getAllEmail(
|
||||
args.session,
|
||||
args.accountId,
|
||||
sort: <Comparator>{}..add(
|
||||
EmailComparator(EmailComparatorProperty.receivedAt)
|
||||
..setIsAscending(false)),
|
||||
filter: EmailFilterCondition(inMailbox: args.trashMailboxId, before: lastEmail?.receivedAt),
|
||||
properties: Properties({EmailProperty.id}));
|
||||
|
||||
var newEmailList = emailsResponse.emailList ?? <Email>[];
|
||||
if (lastEmail != null) {
|
||||
@@ -89,6 +93,7 @@ class ThreadIsolateWorker {
|
||||
}
|
||||
|
||||
Future<List<EmailId>> _emptyTrashFolderOnWeb(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
MailboxId trashMailboxId,
|
||||
Future<void> Function(List<EmailId> newDestroyed) updateDestroyedEmailCache,
|
||||
@@ -99,12 +104,14 @@ class ThreadIsolateWorker {
|
||||
Email? lastEmail;
|
||||
|
||||
while (hasEmails) {
|
||||
final emailsResponse = await _threadAPI.getAllEmail(accountId,
|
||||
sort: <Comparator>{}..add(
|
||||
EmailComparator(EmailComparatorProperty.receivedAt)
|
||||
..setIsAscending(false)),
|
||||
filter: EmailFilterCondition(inMailbox: trashMailboxId, before: lastEmail?.receivedAt),
|
||||
properties: Properties({EmailProperty.id}));
|
||||
final emailsResponse = await _threadAPI.getAllEmail(
|
||||
session,
|
||||
accountId,
|
||||
sort: <Comparator>{}..add(
|
||||
EmailComparator(EmailComparatorProperty.receivedAt)
|
||||
..setIsAscending(false)),
|
||||
filter: EmailFilterCondition(inMailbox: trashMailboxId, before: lastEmail?.receivedAt),
|
||||
properties: Properties({EmailProperty.id}));
|
||||
|
||||
var newEmailList = emailsResponse.emailList ?? <Email>[];
|
||||
if (lastEmail != null) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:dartz/dartz.dart' as dartz;
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/filter/filter.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
@@ -32,6 +33,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
|
||||
@override
|
||||
Stream<EmailsResponse> getAllEmail(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
@@ -58,6 +60,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
if (!localEmailResponse.hasEmails()
|
||||
|| (localEmailResponse.emailList?.length ?? 0) < ThreadConstants.defaultLimit.value) {
|
||||
networkEmailResponse = await mapDataSource[DataSourceType.network]!.getAllEmail(
|
||||
session,
|
||||
accountId,
|
||||
limit: limit,
|
||||
sort: sort,
|
||||
@@ -65,6 +68,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
properties: propertiesCreated);
|
||||
if (_isApproveFilterOption(emailFilter?.filterOption, networkEmailResponse.emailList)) {
|
||||
_getFirstPage(
|
||||
session,
|
||||
accountId,
|
||||
sort: sort,
|
||||
mailboxId: emailFilter?.mailboxId,
|
||||
@@ -83,6 +87,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
if (localEmailResponse.hasState()) {
|
||||
log('ThreadRepositoryImpl::getAllEmail(): filter = ${emailFilter?.mailboxId} local has state: ${localEmailResponse.state}');
|
||||
await _synchronizeCacheWithChanges(
|
||||
session,
|
||||
accountId,
|
||||
localEmailResponse.state!,
|
||||
propertiesCreated: propertiesCreated,
|
||||
@@ -116,6 +121,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
}
|
||||
|
||||
Future<EmailsResponse> _getFirstPage(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
{
|
||||
Set<Comparator>? sort,
|
||||
@@ -125,6 +131,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
}
|
||||
) async {
|
||||
final networkEmailResponse = await mapDataSource[DataSourceType.network]!.getAllEmail(
|
||||
session,
|
||||
accountId,
|
||||
limit: ThreadConstants.defaultLimit,
|
||||
sort: sort,
|
||||
@@ -187,17 +194,19 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
|
||||
@override
|
||||
Stream<EmailsResponse> refreshChanges(
|
||||
AccountId accountId,
|
||||
State currentState,
|
||||
{
|
||||
Set<Comparator>? sort,
|
||||
EmailFilter? emailFilter,
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated,
|
||||
}
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
State currentState,
|
||||
{
|
||||
Set<Comparator>? sort,
|
||||
EmailFilter? emailFilter,
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated,
|
||||
}
|
||||
) async* {
|
||||
log('ThreadRepositoryImpl::refreshChanges(): $currentState');
|
||||
await _synchronizeCacheWithChanges(
|
||||
session,
|
||||
accountId,
|
||||
currentState,
|
||||
propertiesCreated: propertiesCreated,
|
||||
@@ -214,6 +223,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
if (!newEmailResponse.hasEmails()
|
||||
|| (newEmailResponse.emailList?.length ?? 0) < ThreadConstants.defaultLimit.value) {
|
||||
final networkEmailResponse = await _getFirstPage(
|
||||
session,
|
||||
accountId,
|
||||
sort: sort,
|
||||
filter: emailFilter?.filter,
|
||||
@@ -237,14 +247,15 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
Future<EmailsResponse> _getAllEmailsWithoutLastEmailId(GetEmailRequest emailRequest) async {
|
||||
final emailResponse = await mapDataSource[DataSourceType.network]!
|
||||
.getAllEmail(
|
||||
emailRequest.accountId,
|
||||
limit: emailRequest.limit,
|
||||
sort: emailRequest.sort,
|
||||
filter: emailRequest.filter,
|
||||
properties: emailRequest.properties)
|
||||
emailRequest.session,
|
||||
emailRequest.accountId,
|
||||
limit: emailRequest.limit,
|
||||
sort: emailRequest.sort,
|
||||
filter: emailRequest.filter,
|
||||
properties: emailRequest.properties)
|
||||
.then((response) {
|
||||
var listEmails = response.emailList;
|
||||
return EmailsResponse(emailList: listEmails, state: response.state);
|
||||
final listEmails = response.emailList;
|
||||
return EmailsResponse(emailList: listEmails, state: response.state);
|
||||
});
|
||||
|
||||
return emailResponse;
|
||||
@@ -252,6 +263,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
|
||||
@override
|
||||
Future<List<Email>> searchEmails(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
@@ -261,6 +273,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
}
|
||||
) async {
|
||||
final emailResponse = await mapDataSource[DataSourceType.network]!.getAllEmail(
|
||||
session,
|
||||
accountId,
|
||||
limit: limit,
|
||||
sort: sort,
|
||||
@@ -271,8 +284,9 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<EmailId>> emptyTrashFolder(AccountId accountId, MailboxId trashMailboxId) async {
|
||||
Future<List<EmailId>> emptyTrashFolder(Session session, AccountId accountId, MailboxId trashMailboxId) async {
|
||||
return mapDataSource[DataSourceType.network]!.emptyTrashFolder(
|
||||
session,
|
||||
accountId,
|
||||
trashMailboxId,
|
||||
(listEmailIdDeleted) async {
|
||||
@@ -282,6 +296,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
}
|
||||
|
||||
Future<void> _synchronizeCacheWithChanges(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
State currentState,
|
||||
{
|
||||
@@ -299,10 +314,11 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
while(hasMoreChanges && sinceState != null) {
|
||||
log('ThreadRepositoryImpl::_synchronizeCacheWithChanges(): sinceState = $sinceState');
|
||||
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(
|
||||
accountId,
|
||||
sinceState,
|
||||
propertiesCreated: propertiesCreated,
|
||||
propertiesUpdated: propertiesUpdated);
|
||||
session,
|
||||
accountId,
|
||||
sinceState,
|
||||
propertiesCreated: propertiesCreated,
|
||||
propertiesUpdated: propertiesUpdated);
|
||||
|
||||
hasMoreChanges = changesResponse.hasMoreChanges;
|
||||
sinceState = changesResponse.newStateChanges;
|
||||
@@ -337,7 +353,12 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PresentationEmail> getEmailById(AccountId accountId, EmailId emailId, {Properties? properties}) {
|
||||
return mapDataSource[DataSourceType.network]!.getEmailById(accountId, emailId, properties: properties);
|
||||
Future<PresentationEmail> getEmailById(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
EmailId emailId,
|
||||
{Properties? properties}
|
||||
) {
|
||||
return mapDataSource[DataSourceType.network]!.getEmailById(session, accountId, emailId, properties: properties);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user