From 06adc9e6a8970f704d8e4e7bd0821c814f1e9b86 Mon Sep 17 00:00:00 2001 From: Dat PHAM HOANG Date: Mon, 30 Dec 2024 22:15:38 +0700 Subject: [PATCH] TF-3372 Use viewStateMailboxActionProgress to build progress bar for not only MarkAsRead but also Empty mailbox action --- .../mailbox_dashboard_controller.dart | 26 +++++++++++++++---- .../mailbox_dashboard_view_web.dart | 2 +- .../thread/presentation/thread_view.dart | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) 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 7966608a7..b8f2bb98e 100644 --- a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart +++ b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart @@ -225,7 +225,7 @@ class MailboxDashBoardController extends ReloadableController final filterMessageOption = FilterMessageOption.all.obs; final listEmailSelected = [].obs; final composerOverlayState = ComposerOverlayState.inActive.obs; - final viewStateMarkAsReadMailbox = Rx>(Right(UIState.idle)); + final viewStateMailboxActionProgress = Rx>(Right(UIState.idle)); final vacationResponse = Rxn(); final routerParameters = Rxn>(); final _isDraggingMailbox = RxBool(false); @@ -559,7 +559,7 @@ class MailboxDashBoardController extends ReloadableController void _registerStreamListener() { progressState.listen((state) { - viewStateMarkAsReadMailbox.value = state; + viewStateMailboxActionProgress.value = state; }); _refreshActionEventController.stream @@ -1395,6 +1395,8 @@ class MailboxDashBoardController extends ReloadableController } void _emptyTrashFolderSuccess(EmptyTrashFolderSuccess success) { + viewStateMailboxActionProgress.value = Right(UIState.idle); + if (currentOverlayContext != null && currentContext != null) { appToast.showToastSuccessMessage( currentOverlayContext!, @@ -1537,7 +1539,7 @@ class MailboxDashBoardController extends ReloadableController } void _markAsReadMailboxSuccess(Success success) { - viewStateMarkAsReadMailbox.value = Right(UIState.idle); + viewStateMailboxActionProgress.value = Right(UIState.idle); if (success is MarkAsMailboxReadAllSuccess) { if (currentContext != null && currentOverlayContext != null) { @@ -1557,7 +1559,7 @@ class MailboxDashBoardController extends ReloadableController } void _markAsReadMailboxFailure(MarkAsMailboxReadFailure failure) { - viewStateMarkAsReadMailbox.value = Right(UIState.idle); + viewStateMailboxActionProgress.value = Right(UIState.idle); if (currentOverlayContext != null && currentContext != null) { appToast.showToastErrorMessage( currentOverlayContext!, @@ -1569,7 +1571,7 @@ class MailboxDashBoardController extends ReloadableController } void _markAsReadMailboxAllFailure(MarkAsMailboxReadAllFailure failure) { - viewStateMarkAsReadMailbox.value = Right(UIState.idle); + viewStateMailboxActionProgress.value = Right(UIState.idle); if (currentOverlayContext != null && currentContext != null) { appToast.showToastErrorMessage( currentOverlayContext!, @@ -2392,6 +2394,8 @@ class MailboxDashBoardController extends ReloadableController } void _emptySpamFolderSuccess(EmptySpamFolderSuccess success) { + viewStateMailboxActionProgress.value = Right(UIState.idle); + if (currentOverlayContext != null && currentContext != null) { appToast.showToastSuccessMessage( currentOverlayContext!, @@ -2776,6 +2780,18 @@ class MailboxDashBoardController extends ReloadableController ); } + void _handleEmptySpamFolderFailure(EmptySpamFolderFailure failure) { + viewStateMailboxActionProgress.value = Right(UIState.idle); + + toastManager.showMessageFailure(failure); + } + + void _handleEmptyTrashFolderFailure(EmptyTrashFolderFailure failure) { + viewStateMailboxActionProgress.value = Right(UIState.idle); + + toastManager.showMessageFailure(failure); + } + void _handleGetRestoredDeletedMessageSuccess(GetRestoredDeletedMessageSuccess success) async { if (selectedMailbox.value != null && selectedMailbox.value!.isRecovered) { dispatchEmailUIAction(RefreshChangeEmailAction(null)); diff --git a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart index bef9b16a6..334c542fc 100644 --- a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart +++ b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart @@ -107,7 +107,7 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView { responsiveUtils: controller.responsiveUtils, )), Obx(() => MarkMailboxAsReadLoadingBanner( - viewState: controller.viewStateMarkAsReadMailbox.value, + viewState: controller.viewStateMailboxActionProgress.value, )), const SpamReportBannerWebWidget(), QuotasBannerWidget(), diff --git a/lib/features/thread/presentation/thread_view.dart b/lib/features/thread/presentation/thread_view.dart index a12a60f5a..0e0689040 100644 --- a/lib/features/thread/presentation/thread_view.dart +++ b/lib/features/thread/presentation/thread_view.dart @@ -864,7 +864,7 @@ class ThreadView extends GetWidget Widget _buildMarkAsMailboxReadLoading(BuildContext context) { return Obx(() { - final viewState = controller.mailboxDashBoardController.viewStateMarkAsReadMailbox.value; + final viewState = controller.mailboxDashBoardController.viewStateMailboxActionProgress.value; return viewState.fold( (failure) => const SizedBox.shrink(), (success) {