TF-2302 Fix rename folder
(cherry picked from commit 606ae303f92e711ffd0dbd8975a19c8fa02eb022)
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.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/state.dart' as jmap;
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
@@ -530,13 +531,17 @@ abstract class BaseMailboxController extends BaseController {
|
||||
void refreshMailboxChanges(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
jmap.State currentMailboxState
|
||||
jmap.State currentMailboxState,
|
||||
{Properties? properties}
|
||||
) {
|
||||
if (refreshAllMailboxInteractor != null) {
|
||||
log('BaseMailboxController::refreshMailboxChanges(): currentMailboxState: $currentMailboxState');
|
||||
final newMailboxState = currentMailboxState;
|
||||
log('BaseMailboxController::refreshMailboxChanges(): newMailboxState: $newMailboxState');
|
||||
consumeState(refreshAllMailboxInteractor!.execute(session, accountId, newMailboxState));
|
||||
consumeState(refreshAllMailboxInteractor!.execute(
|
||||
session,
|
||||
accountId,
|
||||
currentMailboxState,
|
||||
properties: properties
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
|
||||
class SetEmailMethodException implements Exception {
|
||||
class SetMethodException implements Exception {
|
||||
|
||||
final Map<Id, SetError> mapErrors;
|
||||
|
||||
SetEmailMethodException(this.mapErrors);
|
||||
SetMethodException(this.mapErrors);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ import 'package:model/extensions/session_extension.dart';
|
||||
import 'package:model/oidc/token.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:tmail_ui_user/features/base/mixin/handle_error_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_email_method_exception.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_method_exception.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/model/email_request.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/exceptions/email_exceptions.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/move_to_mailbox_request.dart';
|
||||
@@ -214,7 +214,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
if (emailCreated != null && mapErrors.isEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
throw SetEmailMethodException(mapErrors);
|
||||
throw SetMethodException(mapErrors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
if (emailCreated != null && mapErrors.isEmpty) {
|
||||
return emailCreated;
|
||||
} else {
|
||||
throw SetEmailMethodException(mapErrors);
|
||||
throw SetMethodException(mapErrors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
if (emailUpdated != null && isEmailDeleted == true && mapErrors.isEmpty) {
|
||||
return emailUpdated;
|
||||
} else {
|
||||
throw SetEmailMethodException(mapErrors);
|
||||
throw SetMethodException(mapErrors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:model/mailbox/mailbox_property.dart';
|
||||
|
||||
class MailboxConstants {
|
||||
static final propertiesDefault = Properties({
|
||||
MailboxProperty.id,
|
||||
MailboxProperty.name,
|
||||
MailboxProperty.parentId,
|
||||
MailboxProperty.role,
|
||||
MailboxProperty.sortOrder,
|
||||
MailboxProperty.isSubscribed,
|
||||
MailboxProperty.totalEmails,
|
||||
MailboxProperty.totalThreads,
|
||||
MailboxProperty.unreadEmails,
|
||||
MailboxProperty.unreadThreads,
|
||||
MailboxProperty.myRights,
|
||||
MailboxProperty.namespace
|
||||
});
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import 'package:tmail_ui_user/features/mailbox/domain/model/subscribe_multiple_m
|
||||
abstract class MailboxRepository {
|
||||
Stream<MailboxResponse> getAllMailbox(Session session, AccountId accountId, {Properties? properties});
|
||||
|
||||
Stream<MailboxResponse> refresh(Session session, AccountId accountId, State currentState);
|
||||
Stream<MailboxResponse> refresh(Session session, AccountId accountId, State currentState, {Properties? properties});
|
||||
|
||||
Future<Mailbox?> createNewMailbox(Session session, AccountId accountId, CreateNewMailboxRequest newMailboxRequest);
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
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';
|
||||
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/state.dart' as jmap_state;
|
||||
import 'package:model/extensions/mailbox_extension.dart';
|
||||
@@ -15,11 +17,17 @@ class RefreshAllMailboxInteractor {
|
||||
|
||||
RefreshAllMailboxInteractor(this._mailboxRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(Session session, AccountId accountId, jmap_state.State currentState) async* {
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
jmap_state.State currentState,
|
||||
{Properties? properties}
|
||||
) async* {
|
||||
try {
|
||||
log('RefreshAllMailboxInteractor::execute:properties: $properties');
|
||||
yield Right<Failure, Success>(RefreshChangesAllMailboxLoading());
|
||||
yield* _mailboxRepository
|
||||
.refresh(session, accountId, currentState)
|
||||
.refresh(session, accountId, currentState, properties: properties)
|
||||
.map(_toGetMailboxState);
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(RefreshChangesAllMailboxFailure(e));
|
||||
|
||||
@@ -16,7 +16,7 @@ class RenameMailboxInteractor {
|
||||
yield Right<Failure, Success>(LoadingRenameMailbox());
|
||||
|
||||
final currentMailboxState = await _mailboxRepository.getMailboxState(session, accountId);
|
||||
|
||||
log('RenameMailboxInteractor::execute:currentMailboxState: $currentMailboxState');
|
||||
final result = await _mailboxRepository.renameMailbox(session, accountId, request);
|
||||
if (result) {
|
||||
yield Right<Failure, Success>(RenameMailboxSuccess(currentMailboxState: currentMailboxState));
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/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/state.dart' as jmap;
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
@@ -27,6 +28,7 @@ import 'package:tmail_ui_user/features/email/domain/state/delete_multiple_emails
|
||||
import 'package:tmail_ui_user/features/email/domain/state/mark_as_email_read_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/move_to_mailbox_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/model/composer_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/constants/mailbox_constants.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/create_new_mailbox_request.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/mailbox_subscribe_action_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/mailbox_subscribe_state.dart';
|
||||
@@ -170,7 +172,10 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
|
||||
} else if (success is DeleteMultipleMailboxHasSomeSuccess) {
|
||||
_deleteMultipleMailboxSuccess(success.listMailboxIdDeleted, success.currentMailboxState);
|
||||
} else if (success is RenameMailboxSuccess) {
|
||||
_refreshMailboxChanges(currentMailboxState: success.currentMailboxState);
|
||||
_refreshMailboxChanges(
|
||||
currentMailboxState: success.currentMailboxState,
|
||||
properties: MailboxConstants.propertiesDefault
|
||||
);
|
||||
} else if (success is MoveMailboxSuccess) {
|
||||
_moveMailboxSuccess(success);
|
||||
} else if (success is SubscribeMailboxSuccess) {
|
||||
@@ -315,14 +320,19 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
|
||||
}
|
||||
}
|
||||
|
||||
void _refreshMailboxChanges({jmap.State? currentMailboxState}) {
|
||||
void _refreshMailboxChanges({jmap.State? currentMailboxState, Properties? properties}) {
|
||||
log('MailboxController::_refreshMailboxChanges(): currentMailboxState: $currentMailboxState');
|
||||
final newMailboxState = currentMailboxState ?? this.currentMailboxState;
|
||||
log('MailboxController::_refreshMailboxChanges(): newMailboxState: $newMailboxState');
|
||||
final accountId = mailboxDashBoardController.accountId.value;
|
||||
final session = mailboxDashBoardController.sessionCurrent;
|
||||
if (accountId != null && session != null && newMailboxState != null) {
|
||||
refreshMailboxChanges(session, accountId, newMailboxState);
|
||||
refreshMailboxChanges(
|
||||
session,
|
||||
accountId,
|
||||
newMailboxState,
|
||||
properties: properties
|
||||
);
|
||||
} else {
|
||||
_newFolderId = null;
|
||||
}
|
||||
@@ -1058,6 +1068,7 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
|
||||
|
||||
void _handleGetAllMailboxSuccess(GetAllMailboxSuccess success) async {
|
||||
currentMailboxState = success.currentMailboxState;
|
||||
log('MailboxController::_handleGetAllMailboxSuccess:currentMailboxState: $currentMailboxState');
|
||||
final listMailboxDisplayed = success.mailboxList.listSubscribedMailboxesAndDefaultMailboxes;
|
||||
await buildTree(listMailboxDisplayed);
|
||||
if (currentContext != null) {
|
||||
@@ -1067,6 +1078,7 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
|
||||
|
||||
void _handleRefreshChangesAllMailboxSuccess(RefreshChangesAllMailboxSuccess success) async {
|
||||
currentMailboxState = success.currentMailboxState;
|
||||
log('MailboxController::_handleRefreshChangesAllMailboxSuccess:currentMailboxState: $currentMailboxState');
|
||||
final listMailboxDisplayed = success.mailboxList.listSubscribedMailboxesAndDefaultMailboxes;
|
||||
await refreshTree(listMailboxDisplayed);
|
||||
if (currentContext != null) {
|
||||
|
||||
+4
-4
@@ -24,7 +24,7 @@ import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
import 'package:rxdart/transformers.dart';
|
||||
import 'package:tmail_ui_user/features/base/action/ui_action.dart';
|
||||
import 'package:tmail_ui_user/features/base/reloadable/reloadable_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_email_method_exception.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_method_exception.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/extensions/email_request_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/model/email_request.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/get_autocomplete_state.dart';
|
||||
@@ -1757,7 +1757,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
}
|
||||
final exception = failure.exception;
|
||||
logError('MailboxDashBoardController::_handleSendEmailFailure():exception: $exception');
|
||||
if (exception is SetEmailMethodException) {
|
||||
if (exception is SetMethodException) {
|
||||
final listErrors = exception.mapErrors.values.toList();
|
||||
final toastSuccess = _handleSetErrors(listErrors);
|
||||
if (!toastSuccess) {
|
||||
@@ -1801,7 +1801,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
}
|
||||
final exception = failure.exception;
|
||||
logError('MailboxDashBoardController::_handleSaveEmailAsDraftsFailure():exception: $exception');
|
||||
if (exception is SetEmailMethodException) {
|
||||
if (exception is SetMethodException) {
|
||||
final listErrors = exception.mapErrors.values.toList();
|
||||
final toastSuccess = _handleSetErrors(listErrors);
|
||||
if (!toastSuccess) {
|
||||
@@ -1822,7 +1822,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
}
|
||||
final exception = failure.exception;
|
||||
logError('MailboxDashBoardController::_handleUpdateEmailAsDraftsFailure():exception: $exception');
|
||||
if (exception is SetEmailMethodException) {
|
||||
if (exception is SetMethodException) {
|
||||
final listErrors = exception.mapErrors.values.toList();
|
||||
final toastSuccess = _handleSetErrors(listErrors);
|
||||
if (!toastSuccess) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/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/state.dart' as jmap;
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
@@ -24,6 +25,7 @@ import 'package:model/mailbox/presentation_mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_mailbox_controller.dart';
|
||||
import 'package:tmail_ui_user/features/base/mixin/mailbox_action_handler_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/move_action.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/constants/mailbox_constants.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/create_new_mailbox_request.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/mailbox_subscribe_action_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/mailbox_subscribe_state.dart';
|
||||
@@ -153,7 +155,10 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
|
||||
} else if (success is MarkAsMailboxReadHasSomeEmailFailure) {
|
||||
_refreshMailboxChanges(mailboxState: success.currentMailboxState);
|
||||
} else if (success is RenameMailboxSuccess) {
|
||||
_refreshMailboxChanges(mailboxState: success.currentMailboxState);
|
||||
_refreshMailboxChanges(
|
||||
mailboxState: success.currentMailboxState,
|
||||
properties: MailboxConstants.propertiesDefault
|
||||
);
|
||||
} else if (success is MoveMailboxSuccess) {
|
||||
_moveMailboxSuccess(success);
|
||||
} else if (success is DeleteMultipleMailboxAllSuccess) {
|
||||
@@ -192,13 +197,18 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
|
||||
}
|
||||
}
|
||||
|
||||
void _refreshMailboxChanges({jmap.State? mailboxState}) {
|
||||
void _refreshMailboxChanges({jmap.State? mailboxState, Properties? properties}) {
|
||||
dashboardController.dispatchMailboxUIAction(RefreshChangeMailboxAction(null));
|
||||
final newMailboxState = mailboxState ?? currentMailboxState;
|
||||
final accountId = dashboardController.accountId.value;
|
||||
final session = dashboardController.sessionCurrent;
|
||||
if (session != null && accountId != null && newMailboxState != null) {
|
||||
refreshMailboxChanges(session, accountId, newMailboxState);
|
||||
refreshMailboxChanges(
|
||||
session,
|
||||
accountId,
|
||||
newMailboxState,
|
||||
properties: properties
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user