diff --git a/lib/features/base/mixin/mailbox_action_handler_mixin.dart b/lib/features/base/mixin/mailbox_action_handler_mixin.dart index bf23a00edc..ca34bba977 100644 --- a/lib/features/base/mixin/mailbox_action_handler_mixin.dart +++ b/lib/features/base/mixin/mailbox_action_handler_mixin.dart @@ -131,7 +131,7 @@ mixin MailboxActionHandlerMixin { ..onConfirmAction(AppLocalizations.of(context).delete_all, () { popBack(); if (mailbox.countTotalEmails > 0) { - dashboardController.emptySpamFolderAction(spamFolderId: mailbox.id); + dashboardController.emptySpamFolderAction(spamFolderId: mailbox.id, totalEmails: mailbox.countTotalEmails); } else { appToast.showToastWarningMessage( context, @@ -156,7 +156,7 @@ mixin MailboxActionHandlerMixin { ..onConfirmButtonAction(AppLocalizations.of(context).delete_all, () { popBack(); if (mailbox.countTotalEmails > 0) { - dashboardController.emptySpamFolderAction(spamFolderId: mailbox.id); + dashboardController.emptySpamFolderAction(spamFolderId: mailbox.id, totalEmails: mailbox.countTotalEmails); } else { appToast.showToastWarningMessage( context, diff --git a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart index 3e6b323840..8fafc74f2d 100644 --- a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart +++ b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart @@ -1396,12 +1396,14 @@ class MailboxDashBoardController extends ReloadableController onCancelSelectionEmail?.call(); final trashMailboxId = trashFolderId ?? mapDefaultMailboxIdByRole[PresentationMailbox.roleTrash]; + final trashMailbox = mapMailboxById[trashMailboxId]; + final totalEmailsInTrash = totalEmails == 0 ? trashMailbox?.countTotalEmails : totalEmails; if (sessionCurrent != null && accountId.value != null && trashMailboxId != null) { consumeState(_emptyTrashFolderInteractor.execute( sessionCurrent!, accountId.value!, trashMailboxId, - totalEmails, + totalEmailsInTrash ?? 0, _progressStateController )); } @@ -2458,7 +2460,7 @@ class MailboxDashBoardController extends ReloadableController ..onConfirmAction(AppLocalizations.of(context).delete_all, () { popBack(); if (spamMailbox.countTotalEmails > 0) { - emptySpamFolderAction(spamFolderId: spamMailbox.id); + emptySpamFolderAction(spamFolderId: spamMailbox.id, totalEmails: spamMailbox.countTotalEmails); } else { appToast.showToastWarningMessage( context, @@ -2483,7 +2485,7 @@ class MailboxDashBoardController extends ReloadableController ..onConfirmButtonAction(AppLocalizations.of(context).delete_all, () { popBack(); if (spamMailbox.countTotalEmails > 0) { - emptySpamFolderAction(spamFolderId: spamMailbox.id); + emptySpamFolderAction(spamFolderId: spamMailbox.id, totalEmails: spamMailbox.countTotalEmails); } else { appToast.showToastWarningMessage( context, diff --git a/lib/features/thread/data/network/thread_isolate_worker.dart b/lib/features/thread/data/network/thread_isolate_worker.dart index bd9a8b37b2..b241b2e397 100644 --- a/lib/features/thread/data/network/thread_isolate_worker.dart +++ b/lib/features/thread/data/network/thread_isolate_worker.dart @@ -61,7 +61,7 @@ class ThreadIsolateWorker { fun1: _emptyMailboxFolderAction, notification: (value) { if (value is List) { - log('ThreadIsolateWorker::emptyMailboxFolder(): onUpdateProgress ${value.length / totalEmails}'); + log('ThreadIsolateWorker::emptyMailboxFolder(): processed ${value.length} - totalEmails $totalEmails'); onProgressController.add(Right(EmptyingFolderState( mailboxId, value.length, totalEmails ))); diff --git a/lib/l10n/intl_messages.arb b/lib/l10n/intl_messages.arb index ababfd56d1..c86038fb03 100644 --- a/lib/l10n/intl_messages.arb +++ b/lib/l10n/intl_messages.arb @@ -1,5 +1,5 @@ { - "@@last_modified": "2024-10-31T13:18:32.336494", + "@@last_modified": "2024-12-31T12:11:05.777668", "initializing_data": "Initializing data...", "@initializing_data": { "type": "text", @@ -3970,6 +3970,12 @@ "placeholders_order": [], "placeholders": {} }, + "emptyTrashFolderFailed": "Empty trash folder failed", + "@emptyTrashFolderFailed": { + "type": "text", + "placeholders_order": [], + "placeholders": {} + }, "markAsSpamFailed": "Mark as spam failed", "@markAsSpamFailed": { "type": "text", diff --git a/lib/main/localizations/app_localizations.dart b/lib/main/localizations/app_localizations.dart index 01ff076bd1..0af16a8f84 100644 --- a/lib/main/localizations/app_localizations.dart +++ b/lib/main/localizations/app_localizations.dart @@ -4162,6 +4162,12 @@ class AppLocalizations { name: 'emptySpamFolderFailed'); } + String get emptyTrashFolderFailed { + return Intl.message( + 'Empty trash folder failed', + name: 'emptyTrashFolderFailed'); + } + String get markAsSpamFailed { return Intl.message( 'Mark as spam failed', diff --git a/lib/main/utils/toast_manager.dart b/lib/main/utils/toast_manager.dart index 595b20f6a4..fd0d076bbf 100644 --- a/lib/main/utils/toast_manager.dart +++ b/lib/main/utils/toast_manager.dart @@ -12,6 +12,7 @@ import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_ex import 'package:tmail_ui_user/features/starting_page/domain/state/sign_in_twake_workplace_state.dart'; import 'package:tmail_ui_user/features/starting_page/domain/state/sign_up_twake_workplace_state.dart'; import 'package:tmail_ui_user/features/thread/domain/state/empty_spam_folder_state.dart'; +import 'package:tmail_ui_user/features/thread/domain/state/empty_trash_folder_state.dart'; import 'package:tmail_ui_user/features/thread/domain/state/move_multiple_email_to_mailbox_state.dart'; import 'package:tmail_ui_user/main/exceptions/remote_exception.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; @@ -63,6 +64,8 @@ class ToastManager { ?? AppLocalizations.of(currentContext!).unknownError; } else if (failure is EmptySpamFolderFailure) { message = AppLocalizations.of(currentContext!).emptySpamFolderFailed; + } else if (failure is EmptyTrashFolderFailure) { + message = AppLocalizations.of(currentContext!).emptyTrashFolderFailed; } else if (failure is MoveMultipleEmailToMailboxFailure && failure.emailActionType == EmailActionType.moveToSpam && failure.moveAction == MoveAction.moving) {