TF-2302 Fix rename folder
(cherry picked from commit 606ae303f92e711ffd0dbd8975a19c8fa02eb022)
This commit is contained in:
@@ -25,7 +25,7 @@ abstract class MailboxDataSource {
|
||||
|
||||
Future<List<Mailbox>> getAllMailboxCache(AccountId accountId, UserName userName);
|
||||
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState);
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState, {Properties? properties});
|
||||
|
||||
Future<void> update(AccountId accountId, UserName userName, {List<Mailbox>? updated, List<Mailbox>? created, List<MailboxId>? destroyed});
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class MailboxCacheDataSourceImpl extends MailboxDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState) {
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState, {Properties? properties}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ class MailboxDataSourceImpl extends MailboxDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState) {
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState, {Properties? properties}) {
|
||||
return Future.sync(() async {
|
||||
return await mailboxAPI.getChanges(session, accountId, sinceState);
|
||||
return await mailboxAPI.getChanges(session, accountId, sinceState, properties: properties);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import 'package:jmap_dart_client/jmap/mail/mailbox/set/set_mailbox_response.dart
|
||||
import 'package:model/error_type_handler/set_method_error_handler_mixin.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/base/mixin/handle_error_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_method_exception.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_change_response.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/exceptions/set_mailbox_method_exception.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/extensions/list_mailbox_id_extension.dart';
|
||||
@@ -54,6 +55,8 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
|
||||
final getMailboxCreated = GetMailboxMethod(accountId);
|
||||
|
||||
if (properties != null) getMailboxCreated.addProperties(properties);
|
||||
|
||||
final queryInvocation = jmapRequestBuilder.invocation(getMailboxCreated);
|
||||
|
||||
final capabilities = getMailboxCreated.requiredCapabilities
|
||||
@@ -71,7 +74,7 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
return MailboxResponse(mailboxes: resultCreated?.list, state: resultCreated?.state);
|
||||
}
|
||||
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState) async {
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState, {Properties? properties}) async {
|
||||
final processingInvocation = ProcessingInvocation();
|
||||
|
||||
final jmapRequestBuilder = JmapRequestBuilder(httpClient, processingInvocation);
|
||||
@@ -83,10 +86,17 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
final getMailboxUpdated = GetMailboxMethod(accountId)
|
||||
..addReferenceIds(processingInvocation.createResultReference(
|
||||
changesMailboxInvocation.methodCallId,
|
||||
ReferencePath.updatedPath))
|
||||
..addReferenceProperties(processingInvocation.createResultReference(
|
||||
ReferencePath.updatedPath));
|
||||
|
||||
if (properties == null) {
|
||||
getMailboxUpdated
|
||||
.addReferenceProperties(processingInvocation.createResultReference(
|
||||
changesMailboxInvocation.methodCallId,
|
||||
ReferencePath.updatedPropertiesPath));
|
||||
ReferencePath.updatedPropertiesPath
|
||||
));
|
||||
} else {
|
||||
getMailboxUpdated.addProperties(properties);
|
||||
}
|
||||
|
||||
final getMailboxCreated = GetMailboxMethod(accountId)
|
||||
..addReferenceIds(processingInvocation.createResultReference(
|
||||
@@ -117,7 +127,7 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
GetMailboxResponse.deserialize);
|
||||
|
||||
final listMailboxIdDestroyed = resultChanges?.destroyed.map((id) => MailboxId(id)).toList() ?? <MailboxId>[];
|
||||
|
||||
log('MailboxAPI::getChanges:resultUpdated: ${resultUpdated?.toJson().toString()}');
|
||||
return MailboxChangeResponse(
|
||||
updated: resultUpdated?.list,
|
||||
created: resultCreated?.list,
|
||||
@@ -261,19 +271,23 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
.toCapabilitiesSupportTeamMailboxes(session, accountId);
|
||||
|
||||
final response = await (requestBuilder
|
||||
..usings(capabilities))
|
||||
.build()
|
||||
.execute();
|
||||
..usings(capabilities))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
final setMailboxResponse = response.parse<SetMailboxResponse>(
|
||||
setMailboxInvocation.methodCallId,
|
||||
SetMailboxResponse.deserialize);
|
||||
setMailboxInvocation.methodCallId,
|
||||
SetMailboxResponse.deserialize);
|
||||
|
||||
return Future.sync(() async {
|
||||
return setMailboxResponse?.updated?.isNotEmpty == true;
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
if (setMailboxResponse?.updated?.containsKey(request.mailboxId.id) == true) {
|
||||
return true;
|
||||
} else {
|
||||
final listEntriesErrors = handleSetResponse([
|
||||
setMailboxResponse,
|
||||
]);
|
||||
final mapErrors = Map.fromEntries(listEntriesErrors);
|
||||
throw SetMethodException(mapErrors);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> moveMailbox(Session session, AccountId accountId, MoveMailboxRequest request) async {
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:core/data/model/source_type/data_source_type.dart';
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:dartz/dartz.dart' as dartz;
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
|
||||
@@ -52,13 +53,13 @@ class MailboxRepositoryImpl extends MailboxRepository {
|
||||
State? sinceState = localMailboxResponse.state!;
|
||||
|
||||
while(hasMoreChanges && sinceState != null) {
|
||||
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(session, accountId, sinceState);
|
||||
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(session, accountId, sinceState, properties: properties);
|
||||
|
||||
hasMoreChanges = changesResponse.hasMoreChanges;
|
||||
sinceState = changesResponse.newStateChanges;
|
||||
|
||||
final newMailboxUpdated = await _combineMailboxCache(
|
||||
mailboxUpdated: changesResponse.updated,
|
||||
mailboxUpdatedList: changesResponse.updated,
|
||||
updatedProperties: changesResponse.updatedProperties,
|
||||
mailboxCacheList: localMailboxResponse.mailboxes!);
|
||||
|
||||
@@ -94,44 +95,46 @@ class MailboxRepositoryImpl extends MailboxRepository {
|
||||
}
|
||||
|
||||
Future<List<Mailbox>?> _combineMailboxCache({
|
||||
List<Mailbox>? mailboxUpdated,
|
||||
List<Mailbox>? mailboxUpdatedList,
|
||||
Properties? updatedProperties,
|
||||
List<Mailbox>? mailboxCacheList
|
||||
}) async {
|
||||
if (mailboxUpdated != null && mailboxUpdated.isNotEmpty) {
|
||||
final newMailboxUpdated = mailboxUpdated.map((mailboxUpdated) {
|
||||
if (updatedProperties == null) {
|
||||
return mailboxUpdated;
|
||||
if (mailboxUpdatedList == null || mailboxUpdatedList.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
log('MailboxRepositoryImpl::_combineMailboxCache:mailboxUpdatedList: $mailboxUpdatedList');
|
||||
if (updatedProperties == null) {
|
||||
log('MailboxRepositoryImpl::_combineMailboxCache:updatedProperties is null');
|
||||
return mailboxUpdatedList;
|
||||
} else {
|
||||
final newMailboxUpdatedList = mailboxUpdatedList.map((mailboxUpdated) {
|
||||
final mailboxOld = mailboxCacheList?.findMailbox(mailboxUpdated.id!);
|
||||
if (mailboxOld != null) {
|
||||
return mailboxOld.combineMailbox(mailboxUpdated, updatedProperties);
|
||||
} else {
|
||||
final mailboxOld = mailboxCacheList?.findMailbox(mailboxUpdated.id!);
|
||||
if (mailboxOld != null) {
|
||||
return mailboxOld.combineMailbox(mailboxUpdated, updatedProperties);
|
||||
} else {
|
||||
return mailboxUpdated;
|
||||
}
|
||||
return mailboxUpdated;
|
||||
}
|
||||
}).toList();
|
||||
|
||||
return newMailboxUpdated;
|
||||
log('MailboxRepositoryImpl::_combineMailboxCache:newMailboxUpdatedList: ${newMailboxUpdatedList.length}');
|
||||
return newMailboxUpdatedList;
|
||||
}
|
||||
return mailboxUpdated;
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<MailboxResponse> refresh(Session session, AccountId accountId, State currentState) async* {
|
||||
Stream<MailboxResponse> refresh(Session session, AccountId accountId, State currentState, {Properties? properties}) async* {
|
||||
final localMailboxList = await mapDataSource[DataSourceType.local]!.getAllMailboxCache(accountId, session.username);
|
||||
|
||||
bool hasMoreChanges = true;
|
||||
State? sinceState = currentState;
|
||||
|
||||
while(hasMoreChanges && sinceState != null) {
|
||||
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(session, accountId, sinceState);
|
||||
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(session, accountId, sinceState, properties: properties);
|
||||
|
||||
hasMoreChanges = changesResponse.hasMoreChanges;
|
||||
sinceState = changesResponse.newStateChanges;
|
||||
|
||||
final newMailboxUpdated = await _combineMailboxCache(
|
||||
mailboxUpdated: changesResponse.updated,
|
||||
mailboxUpdatedList: changesResponse.updated,
|
||||
updatedProperties: changesResponse.updatedProperties,
|
||||
mailboxCacheList: localMailboxList);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user