Skip to content

Commit

Permalink
TF-3372 Use viewStateMailboxActionProgress to build progress bar for …
Browse files Browse the repository at this point in the history
…not only MarkAsRead but also Empty mailbox action
  • Loading branch information
hoangdat committed Dec 30, 2024
1 parent 410a70a commit ade3a3e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class MailboxDashBoardController extends ReloadableController
final filterMessageOption = FilterMessageOption.all.obs;
final listEmailSelected = <PresentationEmail>[].obs;
final composerOverlayState = ComposerOverlayState.inActive.obs;
final viewStateMarkAsReadMailbox = Rx<Either<Failure, Success>>(Right(UIState.idle));
final viewStateMailboxActionProgress = Rx<Either<Failure, Success>>(Right(UIState.idle));
final vacationResponse = Rxn<VacationResponse>();
final routerParameters = Rxn<Map<String, dynamic>>();
final _isDraggingMailbox = RxBool(false);
Expand Down Expand Up @@ -559,7 +559,7 @@ class MailboxDashBoardController extends ReloadableController

void _registerStreamListener() {
progressState.listen((state) {
viewStateMarkAsReadMailbox.value = state;
viewStateMailboxActionProgress.value = state;
});

_refreshActionEventController.stream
Expand Down Expand Up @@ -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!,
Expand Down Expand Up @@ -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) {
Expand All @@ -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!,
Expand All @@ -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!,
Expand Down Expand Up @@ -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!,
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
responsiveUtils: controller.responsiveUtils,
)),
Obx(() => MarkMailboxAsReadLoadingBanner(
viewState: controller.viewStateMarkAsReadMailbox.value,
viewState: controller.viewStateMailboxActionProgress.value,
)),
const SpamReportBannerWebWidget(),
QuotasBannerWidget(),
Expand Down
2 changes: 1 addition & 1 deletion lib/features/thread/presentation/thread_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ class ThreadView extends GetWidget<ThreadController>

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) {
Expand Down

0 comments on commit ade3a3e

Please sign in to comment.