TF-1080 Implement delete multiple mailbox folder
This commit is contained in:
@@ -1,19 +1,40 @@
|
|||||||
import 'package:core/core.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||||
import 'package:tmail_ui_user/features/base/state/ui_action_state.dart';
|
import 'package:tmail_ui_user/features/base/state/ui_action_state.dart';
|
||||||
|
|
||||||
class DeleteMultipleMailboxSuccess extends UIActionState {
|
class DeleteMultipleMailboxAllSuccess extends UIActionState {
|
||||||
|
|
||||||
final MailboxId mailboxIdDeleted;
|
final List<MailboxId> listMailboxIdDeleted;
|
||||||
|
|
||||||
DeleteMultipleMailboxSuccess(this.mailboxIdDeleted, {
|
DeleteMultipleMailboxAllSuccess(this.listMailboxIdDeleted, {
|
||||||
jmap.State? currentEmailState,
|
jmap.State? currentEmailState,
|
||||||
jmap.State? currentMailboxState,
|
jmap.State? currentMailboxState,
|
||||||
}) : super(currentEmailState, currentMailboxState);
|
}) : super(currentEmailState, currentMailboxState);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [mailboxIdDeleted];
|
List<Object?> get props => [listMailboxIdDeleted];
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeleteMultipleMailboxHasSomeSuccess extends UIActionState {
|
||||||
|
|
||||||
|
final List<MailboxId> listMailboxIdDeleted;
|
||||||
|
|
||||||
|
DeleteMultipleMailboxHasSomeSuccess(this.listMailboxIdDeleted, {
|
||||||
|
jmap.State? currentEmailState,
|
||||||
|
jmap.State? currentMailboxState,
|
||||||
|
}) : super(currentEmailState, currentMailboxState);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [listMailboxIdDeleted];
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeleteMultipleMailboxAllFailure extends FeatureFailure {
|
||||||
|
|
||||||
|
DeleteMultipleMailboxAllFailure();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteMultipleMailboxFailure extends FeatureFailure {
|
class DeleteMultipleMailboxFailure extends FeatureFailure {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import 'package:core/core.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';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.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/core/session/session.dart';
|
||||||
@@ -11,17 +13,38 @@ class DeleteMultipleMailboxInteractor {
|
|||||||
|
|
||||||
DeleteMultipleMailboxInteractor(this._mailboxRepository);
|
DeleteMultipleMailboxInteractor(this._mailboxRepository);
|
||||||
|
|
||||||
Stream<Either<Failure, Success>> execute(Session session, AccountId accountId, List<MailboxId> mailboxIds, MailboxId mailboxIdDeleted) async* {
|
Stream<Either<Failure, Success>> execute(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Map<MailboxId, List<MailboxId>> mapMailboxIdToDelete,
|
||||||
|
List<MailboxId> listMailboxIdToDelete
|
||||||
|
) async* {
|
||||||
try {
|
try {
|
||||||
final currentMailboxState = await _mailboxRepository.getMailboxState();
|
final currentMailboxState = await _mailboxRepository.getMailboxState();
|
||||||
final result = await _mailboxRepository.deleteMultipleMailbox(session, accountId, mailboxIds);
|
|
||||||
if (result) {
|
final listResult = await Future.wait(
|
||||||
yield Right<Failure, Success>(DeleteMultipleMailboxSuccess(
|
mapMailboxIdToDelete.keys.map((mailboxId) {
|
||||||
mailboxIdDeleted,
|
final mailboxIdsToDelete = mapMailboxIdToDelete[mailboxId]!;
|
||||||
|
return _mailboxRepository.deleteMultipleMailbox(
|
||||||
|
session,
|
||||||
|
accountId,
|
||||||
|
mailboxIdsToDelete);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
final allSuccess = listResult.every((result) => result);
|
||||||
|
final allFailed = listResult.every((result) => !result);
|
||||||
|
|
||||||
|
if (allSuccess) {
|
||||||
|
yield Right<Failure, Success>(DeleteMultipleMailboxAllSuccess(
|
||||||
|
listMailboxIdToDelete,
|
||||||
currentMailboxState: currentMailboxState));
|
currentMailboxState: currentMailboxState));
|
||||||
|
} else if (allFailed) {
|
||||||
|
yield Left<Failure, Success>(DeleteMultipleMailboxAllFailure());
|
||||||
} else {
|
} else {
|
||||||
logError('DeleteMultipleMailboxInteractor::execute(): failed');
|
yield Right<Failure, Success>(DeleteMultipleMailboxHasSomeSuccess(
|
||||||
yield Left<Failure, Success>(DeleteMultipleMailboxFailure(null));
|
listMailboxIdToDelete,
|
||||||
|
currentMailboxState: currentMailboxState));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError('DeleteMultipleMailboxInteractor::execute(): exception: $e');
|
logError('DeleteMultipleMailboxInteractor::execute(): exception: $e');
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_node.dart';
|
||||||
|
|
||||||
|
extension ListMailboxNodeExtension on List<MailboxNode> {
|
||||||
|
List<MailboxId> get mailboxIds => map((node) => node.item.id).toList();
|
||||||
|
}
|
||||||
@@ -42,6 +42,7 @@ import 'package:tmail_ui_user/features/mailbox/domain/usecases/move_mailbox_inte
|
|||||||
import 'package:tmail_ui_user/features/mailbox/domain/usecases/refresh_all_mailbox_interactor.dart';
|
import 'package:tmail_ui_user/features/mailbox/domain/usecases/refresh_all_mailbox_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/domain/usecases/rename_mailbox_interactor.dart';
|
import 'package:tmail_ui_user/features/mailbox/domain/usecases/rename_mailbox_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/domain/usecases/search_mailbox_interactor.dart';
|
import 'package:tmail_ui_user/features/mailbox/domain/usecases/search_mailbox_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/list_mailbox_node_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_categories.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_categories.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_categories_expand_mode.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_categories_expand_mode.dart';
|
||||||
@@ -173,8 +174,10 @@ class MailboxController extends BaseMailboxController {
|
|||||||
_createNewMailboxSuccess(success);
|
_createNewMailboxSuccess(success);
|
||||||
} else if (success is SearchMailboxSuccess) {
|
} else if (success is SearchMailboxSuccess) {
|
||||||
_searchMailboxSuccess(success);
|
_searchMailboxSuccess(success);
|
||||||
} else if (success is DeleteMultipleMailboxSuccess) {
|
} else if (success is DeleteMultipleMailboxAllSuccess) {
|
||||||
_deleteMailboxSuccess(success);
|
_deleteMultipleMailboxSuccess(success.listMailboxIdDeleted, success.currentMailboxState);
|
||||||
|
} else if (success is DeleteMultipleMailboxHasSomeSuccess) {
|
||||||
|
_deleteMultipleMailboxSuccess(success.listMailboxIdDeleted, success.currentMailboxState);
|
||||||
} else if ((success is GetAllMailboxSuccess || success is RefreshChangesAllMailboxSuccess) && isSearchActive()) {
|
} else if ((success is GetAllMailboxSuccess || success is RefreshChangesAllMailboxSuccess) && isSearchActive()) {
|
||||||
_searchMailboxAction(allMailboxes, searchQuery.value);
|
_searchMailboxAction(allMailboxes, searchQuery.value);
|
||||||
} else if (success is RenameMailboxSuccess) {
|
} else if (success is RenameMailboxSuccess) {
|
||||||
@@ -533,29 +536,35 @@ class MailboxController extends BaseMailboxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pressMailboxSelectionAction(BuildContext context, MailboxActions actions,
|
void pressMailboxSelectionAction(
|
||||||
List<PresentationMailbox> selectionMailbox) {
|
BuildContext context,
|
||||||
|
MailboxActions actions,
|
||||||
|
List<PresentationMailbox> selectedMailboxList
|
||||||
|
) {
|
||||||
switch(actions) {
|
switch(actions) {
|
||||||
case MailboxActions.delete:
|
case MailboxActions.delete:
|
||||||
_openConfirmationDialogDeleteMailboxAction(context, selectionMailbox.first);
|
_openConfirmationDialogDeleteMultipleMailboxAction(context, selectedMailboxList);
|
||||||
break;
|
break;
|
||||||
case MailboxActions.rename:
|
case MailboxActions.rename:
|
||||||
_openDialogRenameMailboxAction(context, selectionMailbox.first);
|
_openDialogRenameMailboxAction(context, selectedMailboxList.first);
|
||||||
break;
|
break;
|
||||||
case MailboxActions.markAsRead:
|
case MailboxActions.markAsRead:
|
||||||
_markAsReadMailboxAction(context, selectionMailbox.first);
|
_markAsReadMailboxAction(context, selectedMailboxList.first);
|
||||||
break;
|
break;
|
||||||
case MailboxActions.move:
|
case MailboxActions.move:
|
||||||
_moveMailboxAction(selectionMailbox.first);
|
_moveMailboxAction(selectedMailboxList.first);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _openConfirmationDialogDeleteMailboxAction(BuildContext context,
|
void _openConfirmationDialogDeleteMailboxAction(
|
||||||
PresentationMailbox presentationMailbox) {
|
BuildContext context,
|
||||||
if (_responsiveUtils.isMobile(context)) {
|
PresentationMailbox presentationMailbox
|
||||||
|
) {
|
||||||
|
if (_responsiveUtils.isLandscapeMobile(context) ||
|
||||||
|
_responsiveUtils.isPortraitMobile(context)) {
|
||||||
(ConfirmationDialogActionSheetBuilder(context)
|
(ConfirmationDialogActionSheetBuilder(context)
|
||||||
..messageText(AppLocalizations.of(context)
|
..messageText(AppLocalizations.of(context)
|
||||||
.message_confirmation_dialog_delete_mailbox(presentationMailbox.name?.name ?? ''))
|
.message_confirmation_dialog_delete_mailbox(presentationMailbox.name?.name ?? ''))
|
||||||
@@ -590,40 +599,130 @@ class MailboxController extends BaseMailboxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _deleteMailboxAction(PresentationMailbox presentationMailbox) {
|
void _deleteMailboxAction(PresentationMailbox presentationMailbox) {
|
||||||
final matchedNode = findMailboxNodeById(presentationMailbox.id);
|
|
||||||
|
|
||||||
final accountId = mailboxDashBoardController.accountId.value;
|
final accountId = mailboxDashBoardController.accountId.value;
|
||||||
final session = mailboxDashBoardController.sessionCurrent;
|
final session = mailboxDashBoardController.sessionCurrent;
|
||||||
|
|
||||||
if (session != null) {
|
if (session != null && accountId != null) {
|
||||||
if (matchedNode != null && accountId != null) {
|
final tupleMap = _generateMapDescendantIdsAndMailboxIdList([presentationMailbox]);
|
||||||
final descendantIds = matchedNode.descendantsAsList()
|
final mapDescendantIds = tupleMap.value1;
|
||||||
.map((node) => node.item.id)
|
final listMailboxId = tupleMap.value2;
|
||||||
.toList();
|
|
||||||
|
|
||||||
final descendantIdsReversed = descendantIds.reversed.toList();
|
consumeState(_deleteMultipleMailboxInteractor.execute(
|
||||||
consumeState(_deleteMultipleMailboxInteractor.execute(
|
session,
|
||||||
session, accountId, descendantIdsReversed, presentationMailbox.id));
|
accountId,
|
||||||
} else {
|
mapDescendantIds,
|
||||||
_deleteMailboxFailure(DeleteMultipleMailboxFailure(null));
|
listMailboxId));
|
||||||
}
|
} else {
|
||||||
|
_deleteMailboxFailure(DeleteMultipleMailboxFailure(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
_cancelSelectMailbox();
|
_cancelSelectMailbox();
|
||||||
popBack();
|
popBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _deleteMailboxSuccess(DeleteMultipleMailboxSuccess success) {
|
void _deleteMultipleMailboxSuccess(
|
||||||
|
List<MailboxId> listMailboxIdDeleted,
|
||||||
|
jmap.State? currentMailboxState
|
||||||
|
) {
|
||||||
if (currentOverlayContext != null && currentContext != null) {
|
if (currentOverlayContext != null && currentContext != null) {
|
||||||
_appToast.showToastWithIcon(
|
_appToast.showToastWithIcon(
|
||||||
currentOverlayContext!,
|
currentOverlayContext!,
|
||||||
message: AppLocalizations.of(currentContext!).delete_mailboxes_successfully,
|
message: AppLocalizations.of(currentContext!).delete_mailboxes_successfully,
|
||||||
icon: _imagePaths.icSelected);
|
icon: _imagePaths.icSelected);
|
||||||
}
|
}
|
||||||
if (success.mailboxIdDeleted == mailboxDashBoardController.selectedMailbox.value?.id) {
|
if (listMailboxIdDeleted.contains(mailboxDashBoardController.selectedMailbox.value?.id)) {
|
||||||
_switchBackToMailboxDefault();
|
_switchBackToMailboxDefault();
|
||||||
}
|
}
|
||||||
refreshMailboxChanges(currentMailboxState: success.currentMailboxState);
|
refreshMailboxChanges(currentMailboxState: currentMailboxState);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _openConfirmationDialogDeleteMultipleMailboxAction(
|
||||||
|
BuildContext context,
|
||||||
|
List<PresentationMailbox> selectedMailboxList
|
||||||
|
) {
|
||||||
|
if (_responsiveUtils.isLandscapeMobile(context) ||
|
||||||
|
_responsiveUtils.isPortraitMobile(context)) {
|
||||||
|
(ConfirmationDialogActionSheetBuilder(context)
|
||||||
|
..messageText(AppLocalizations.of(context)
|
||||||
|
.messageConfirmationDialogDeleteMultipleMailbox(selectedMailboxList.length))
|
||||||
|
..onCancelAction(AppLocalizations.of(context).cancel, () =>
|
||||||
|
popBack())
|
||||||
|
..onConfirmAction(AppLocalizations.of(context).delete, () =>
|
||||||
|
_deleteMultipleMailboxAction(selectedMailboxList)))
|
||||||
|
.show();
|
||||||
|
} else {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||||
|
builder: (BuildContext context) => PointerInterceptor(child: (ConfirmDialogBuilder(_imagePaths)
|
||||||
|
..key(const Key('confirm_dialog_delete_multiple_mailbox'))
|
||||||
|
..title(AppLocalizations.of(context).delete_mailboxes)
|
||||||
|
..content(AppLocalizations.of(context)
|
||||||
|
.messageConfirmationDialogDeleteMultipleMailbox(selectedMailboxList.length))
|
||||||
|
..addIcon(SvgPicture.asset(_imagePaths.icRemoveDialog,
|
||||||
|
fit: BoxFit.fill))
|
||||||
|
..colorConfirmButton(AppColor.colorConfirmActionDialog)
|
||||||
|
..styleTextConfirmButton(const TextStyle(
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: AppColor.colorActionDeleteConfirmDialog))
|
||||||
|
..onCloseButtonAction(() => popBack())
|
||||||
|
..onConfirmButtonAction(AppLocalizations.of(context).delete, () =>
|
||||||
|
_deleteMultipleMailboxAction(selectedMailboxList))
|
||||||
|
..onCancelButtonAction(AppLocalizations.of(context).cancel, () =>
|
||||||
|
popBack()))
|
||||||
|
.build()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tuple2<Map<MailboxId, List<MailboxId>>, List<MailboxId>> _generateMapDescendantIdsAndMailboxIdList(
|
||||||
|
List<PresentationMailbox> selectedMailboxList
|
||||||
|
) {
|
||||||
|
Map<MailboxId, List<MailboxId>> mapDescendantIds = {};
|
||||||
|
List<MailboxId> allMailboxIds = [];
|
||||||
|
|
||||||
|
for (var mailbox in selectedMailboxList) {
|
||||||
|
final currentMailboxId = mailbox.id;
|
||||||
|
|
||||||
|
if (allMailboxIds.contains(currentMailboxId)) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
final matchedNode = findMailboxNodeById(currentMailboxId);
|
||||||
|
|
||||||
|
if (matchedNode != null) {
|
||||||
|
final descendantIds = matchedNode.descendantsAsList().mailboxIds;
|
||||||
|
final descendantIdsReversed = descendantIds.reversed.toList();
|
||||||
|
|
||||||
|
mapDescendantIds[currentMailboxId] = descendantIdsReversed;
|
||||||
|
allMailboxIds.addAll(descendantIdsReversed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log('MailboxController::_generateMapDescendantIdsByMailboxList(): mapDescendantIds: $mapDescendantIds');
|
||||||
|
|
||||||
|
return Tuple2(mapDescendantIds, allMailboxIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _deleteMultipleMailboxAction(List<PresentationMailbox> selectedMailboxList) {
|
||||||
|
final accountId = mailboxDashBoardController.accountId.value;
|
||||||
|
final session = mailboxDashBoardController.sessionCurrent;
|
||||||
|
|
||||||
|
if (session != null && accountId != null) {
|
||||||
|
final tupleMap = _generateMapDescendantIdsAndMailboxIdList(selectedMailboxList);
|
||||||
|
final mapDescendantIds = tupleMap.value1;
|
||||||
|
final listMailboxId = tupleMap.value2;
|
||||||
|
consumeState(_deleteMultipleMailboxInteractor.execute(
|
||||||
|
session,
|
||||||
|
accountId,
|
||||||
|
mapDescendantIds,
|
||||||
|
listMailboxId));
|
||||||
|
} else {
|
||||||
|
_deleteMailboxFailure(DeleteMultipleMailboxFailure(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
_cancelSelectMailbox();
|
||||||
|
popBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _switchBackToMailboxDefault() {
|
void _switchBackToMailboxDefault() {
|
||||||
@@ -817,19 +916,22 @@ class MailboxController extends BaseMailboxController {
|
|||||||
final allChildrenAtMailboxLocation = (defaultMailboxTree.value.root.childrenItems ?? <MailboxNode>[]) + (folderMailboxTree.value.root.childrenItems ?? <MailboxNode>[]);
|
final allChildrenAtMailboxLocation = (defaultMailboxTree.value.root.childrenItems ?? <MailboxNode>[]) + (folderMailboxTree.value.root.childrenItems ?? <MailboxNode>[]);
|
||||||
if (allChildrenAtMailboxLocation.isNotEmpty) {
|
if (allChildrenAtMailboxLocation.isNotEmpty) {
|
||||||
listMailboxNameAsStringExist = allChildrenAtMailboxLocation
|
listMailboxNameAsStringExist = allChildrenAtMailboxLocation
|
||||||
.where((mailboxNode) => mailboxNode.item.name != null && mailboxNode.item.name?.name.isNotEmpty == true)
|
.where((mailboxNode) => mailboxNode.nameNotEmpty)
|
||||||
.map((mailboxNode) => mailboxNode.item.name!.name)
|
.map((mailboxNode) => mailboxNode.mailboxNameAsString)
|
||||||
.toList();
|
.toList();
|
||||||
|
} else {
|
||||||
|
listMailboxNameAsStringExist = [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final mailboxNodeLocation = defaultMailboxTree.value.findNode((node) => node.item.id == mailboxRenamed.parentId)
|
final mailboxNodeLocation = findMailboxNodeById(mailboxRenamed.parentId!);
|
||||||
?? folderMailboxTree.value.findNode((node) => node.item.id == mailboxRenamed.parentId);
|
|
||||||
if (mailboxNodeLocation != null && mailboxNodeLocation.childrenItems?.isNotEmpty == true) {
|
if (mailboxNodeLocation != null && mailboxNodeLocation.childrenItems?.isNotEmpty == true) {
|
||||||
final allChildrenAtMailboxLocation = mailboxNodeLocation.childrenItems!;
|
final allChildrenAtMailboxLocation = mailboxNodeLocation.childrenItems!;
|
||||||
listMailboxNameAsStringExist = allChildrenAtMailboxLocation
|
listMailboxNameAsStringExist = allChildrenAtMailboxLocation
|
||||||
.where((mailboxNode) => mailboxNode.item.name != null && mailboxNode.item.name?.name.isNotEmpty == true)
|
.where((mailboxNode) => mailboxNode.nameNotEmpty)
|
||||||
.map((mailboxNode) => mailboxNode.item.name!.name)
|
.map((mailboxNode) => mailboxNode.mailboxNameAsString)
|
||||||
.toList();
|
.toList();
|
||||||
|
} else {
|
||||||
|
listMailboxNameAsStringExist = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -863,8 +965,11 @@ class MailboxController extends BaseMailboxController {
|
|||||||
mailboxDashBoardController.showAppDashboardAction();
|
mailboxDashBoardController.showAppDashboardAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMailboxAction(BuildContext context, MailboxActions actions,
|
void handleMailboxAction(
|
||||||
PresentationMailbox mailbox) {
|
BuildContext context,
|
||||||
|
MailboxActions actions,
|
||||||
|
PresentationMailbox mailbox
|
||||||
|
) {
|
||||||
popBack();
|
popBack();
|
||||||
|
|
||||||
switch(actions) {
|
switch(actions) {
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ class MailboxNode with EquatableMixin{
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
bool get nameNotEmpty => item.name?.name.isNotEmpty == true;
|
||||||
|
|
||||||
|
String get mailboxNameAsString => item.name?.name ?? '';
|
||||||
|
|
||||||
void addChildNode(MailboxNode node) {
|
void addChildNode(MailboxNode node) {
|
||||||
childrenItems ??= [];
|
childrenItems ??= [];
|
||||||
childrenItems?.add(node);
|
childrenItems?.add(node);
|
||||||
|
|||||||
@@ -117,8 +117,7 @@ class BottomBarSelectionMailboxWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get _isDeleteMailboxValid => _listSelectionMailbox.length == 1
|
bool get _isDeleteMailboxValid => _isAllFolderMailbox;
|
||||||
&& _isAllFolderMailbox;
|
|
||||||
|
|
||||||
bool get _isRenameMailboxValid => _listSelectionMailbox.length == 1
|
bool get _isRenameMailboxValid => _listSelectionMailbox.length == 1
|
||||||
&& _isAllFolderMailbox;
|
&& _isAllFolderMailbox;
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ class MailboxCreatorController extends BaseController {
|
|||||||
folderMailboxTree = arguments.folderMailboxTree;
|
folderMailboxTree = arguments.folderMailboxTree;
|
||||||
defaultMailboxTree = arguments.defaultMailboxTree;
|
defaultMailboxTree = arguments.defaultMailboxTree;
|
||||||
accountId = arguments.accountId;
|
accountId = arguments.accountId;
|
||||||
log('MailboxCreatorController::onReady(): defaultMailboxTree: $defaultMailboxTree');
|
|
||||||
log('MailboxCreatorController::onReady(): folderMailboxTree: $folderMailboxTree');
|
|
||||||
_createListMailboxNameAsStringInMailboxLocation();
|
_createListMailboxNameAsStringInMailboxLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,24 +78,35 @@ class MailboxCreatorController extends BaseController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MailboxNode? _findMailboxNodeById(MailboxId mailboxId) {
|
||||||
|
final mailboxNode = defaultMailboxTree?.findNode((node) => node.item.id == mailboxId);
|
||||||
|
if (mailboxNode != null) {
|
||||||
|
return mailboxNode;
|
||||||
|
}
|
||||||
|
return folderMailboxTree?.findNode((node) => node.item.id == mailboxId);
|
||||||
|
}
|
||||||
|
|
||||||
void _createListMailboxNameAsStringInMailboxLocation() {
|
void _createListMailboxNameAsStringInMailboxLocation() {
|
||||||
if (selectedMailbox.value == null) {
|
if (selectedMailbox.value == null) {
|
||||||
final allChildrenAtMailboxLocation = (defaultMailboxTree?.root.childrenItems ?? <MailboxNode>[]) + (folderMailboxTree?.root.childrenItems ?? <MailboxNode>[]);
|
final allChildrenAtMailboxLocation = (defaultMailboxTree?.root.childrenItems ?? <MailboxNode>[]) + (folderMailboxTree?.root.childrenItems ?? <MailboxNode>[]);
|
||||||
if (allChildrenAtMailboxLocation.isNotEmpty) {
|
if (allChildrenAtMailboxLocation.isNotEmpty) {
|
||||||
listMailboxNameAsStringExist = allChildrenAtMailboxLocation
|
listMailboxNameAsStringExist = allChildrenAtMailboxLocation
|
||||||
.where((mailboxNode) => mailboxNode.item.name != null && mailboxNode.item.name?.name.isNotEmpty == true)
|
.where((mailboxNode) => mailboxNode.nameNotEmpty)
|
||||||
.map((mailboxNode) => mailboxNode.item.name!.name)
|
.map((mailboxNode) => mailboxNode.mailboxNameAsString)
|
||||||
.toList();
|
.toList();
|
||||||
|
} else {
|
||||||
|
listMailboxNameAsStringExist = [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final mailboxNodeLocation = defaultMailboxTree?.findNode((node) => node.item.id == selectedMailbox.value!.id)
|
final mailboxNodeLocation = _findMailboxNodeById(selectedMailbox.value!.id);
|
||||||
?? folderMailboxTree?.findNode((node) => node.item.id == selectedMailbox.value!.id);
|
|
||||||
if (mailboxNodeLocation != null && mailboxNodeLocation.childrenItems?.isNotEmpty == true) {
|
if (mailboxNodeLocation != null && mailboxNodeLocation.childrenItems?.isNotEmpty == true) {
|
||||||
final allChildrenAtMailboxLocation = mailboxNodeLocation.childrenItems!;
|
final allChildrenAtMailboxLocation = mailboxNodeLocation.childrenItems!;
|
||||||
listMailboxNameAsStringExist = allChildrenAtMailboxLocation
|
listMailboxNameAsStringExist = allChildrenAtMailboxLocation
|
||||||
.where((mailboxNode) => mailboxNode.item.name != null && mailboxNode.item.name?.name.isNotEmpty == true)
|
.where((mailboxNode) => mailboxNode.nameNotEmpty)
|
||||||
.map((mailboxNode) => mailboxNode.item.name!.name)
|
.map((mailboxNode) => mailboxNode.mailboxNameAsString)
|
||||||
.toList();
|
.toList();
|
||||||
|
} else {
|
||||||
|
listMailboxNameAsStringExist = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2022-10-21T10:04:34.240729",
|
"@@last_modified": "2022-10-26T13:43:22.314355",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -2383,5 +2383,15 @@
|
|||||||
"placeholders": {
|
"placeholders": {
|
||||||
"numberOfConversation": {}
|
"numberOfConversation": {}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"messageConfirmationDialogDeleteMultipleMailbox": "{numberOfMailbox} mailbox and all of the sub-folders and messages it contains will be deleted and won't be able to recover. Do you want to continue to delete?",
|
||||||
|
"@messageConfirmationDialogDeleteMultipleMailbox": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [
|
||||||
|
"numberOfMailbox"
|
||||||
|
],
|
||||||
|
"placeholders": {
|
||||||
|
"numberOfMailbox": {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2455,4 +2455,12 @@ class AppLocalizations {
|
|||||||
args: [numberOfConversation]
|
args: [numberOfConversation]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String messageConfirmationDialogDeleteMultipleMailbox(int numberOfMailbox) {
|
||||||
|
return Intl.message(
|
||||||
|
'$numberOfMailbox mailbox and all of the sub-folders and messages it contains will be deleted and won\'t be able to recover. Do you want to continue to delete?',
|
||||||
|
name: 'messageConfirmationDialogDeleteMultipleMailbox',
|
||||||
|
args: [numberOfMailbox]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user