From b1c3bd0cf0f6ba3166da544fc4628a83f239e8a2 Mon Sep 17 00:00:00 2001 From: DatDang Date: Tue, 7 Jan 2025 08:34:46 +0700 Subject: [PATCH] fixup! TF-3385 Fix loading forever when empty <20 items mailbox --- .../extensions/move_emails_to_mailbox_extension.dart | 3 ++- lib/features/thread/presentation/thread_controller.dart | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/features/mailbox_dashboard/presentation/extensions/move_emails_to_mailbox_extension.dart b/lib/features/mailbox_dashboard/presentation/extensions/move_emails_to_mailbox_extension.dart index f05bf6cffc..c3634a7b9e 100644 --- a/lib/features/mailbox_dashboard/presentation/extensions/move_emails_to_mailbox_extension.dart +++ b/lib/features/mailbox_dashboard/presentation/extensions/move_emails_to_mailbox_extension.dart @@ -31,7 +31,8 @@ extension MoveEmailsToMailboxExtension on MailboxDashBoardController { final currentMailbox = selectedMailbox.value; final currentTotalEmails = currentMailbox?.totalEmails; if (currentMailbox != null && currentTotalEmails != null) { - final newTotalEmails = currentTotalEmails.value.value.toInt() - movedEmailIds.length; + int newTotalEmails = currentTotalEmails.value.value.toInt() - movedEmailIds.length; + if (newTotalEmails < 0) newTotalEmails = 0; selectedMailbox.value = currentMailbox.copyWith( totalEmails: TotalEmails(UnsignedInt(newTotalEmails)), ); diff --git a/lib/features/thread/presentation/thread_controller.dart b/lib/features/thread/presentation/thread_controller.dart index 467852e057..29a1af535c 100644 --- a/lib/features/thread/presentation/thread_controller.dart +++ b/lib/features/thread/presentation/thread_controller.dart @@ -408,7 +408,8 @@ class ThreadController extends BaseController with EmailActionController { final currentMailbox = mailboxDashBoardController.selectedMailbox.value; final currentTotalEmails = currentMailbox?.totalEmails; if (currentMailbox != null && currentTotalEmails != null) { - final newTotalEmails = currentTotalEmails.value.value.toInt() - deletedEmailsCount; + int newTotalEmails = currentTotalEmails.value.value.toInt() - deletedEmailsCount; + if (newTotalEmails < 0) newTotalEmails = 0; mailboxDashBoardController.selectedMailbox.value = currentMailbox.copyWith( totalEmails: TotalEmails(UnsignedInt(newTotalEmails)), );