diff --git a/lib/features/email/presentation/action/email_ui_action.dart b/lib/features/email/presentation/action/email_ui_action.dart index 9bf6c8b14..ab063f13e 100644 --- a/lib/features/email/presentation/action/email_ui_action.dart +++ b/lib/features/email/presentation/action/email_ui_action.dart @@ -12,9 +12,9 @@ class EmailUIAction extends UIAction { } class RefreshChangeEmailAction extends EmailUIAction { - final jmap.State? newState; + final jmap.State newState; - RefreshChangeEmailAction(this.newState); + RefreshChangeEmailAction({required this.newState}); @override List get props => [newState]; diff --git a/lib/features/mailbox/presentation/action/mailbox_ui_action.dart b/lib/features/mailbox/presentation/action/mailbox_ui_action.dart index aee4db436..fe02896e6 100644 --- a/lib/features/mailbox/presentation/action/mailbox_ui_action.dart +++ b/lib/features/mailbox/presentation/action/mailbox_ui_action.dart @@ -15,9 +15,9 @@ class MailboxUIAction extends UIAction { class SelectMailboxDefaultAction extends MailboxUIAction {} class RefreshChangeMailboxAction extends MailboxUIAction { - final jmap.State? newState; + final jmap.State newState; - RefreshChangeMailboxAction(this.newState); + RefreshChangeMailboxAction({required this.newState}); @override List get props => [newState]; diff --git a/lib/features/mailbox/presentation/mailbox_controller.dart b/lib/features/mailbox/presentation/mailbox_controller.dart index 06d07721a..9ae2ddd8e 100644 --- a/lib/features/mailbox/presentation/mailbox_controller.dart +++ b/lib/features/mailbox/presentation/mailbox_controller.dart @@ -521,12 +521,12 @@ class MailboxController extends BaseMailboxController } } - void _refreshMailboxChanges({jmap.State? newState}) { + void _refreshMailboxChanges({required jmap.State newState}) { log('MailboxController::_refreshMailboxChanges():newState: $newState'); if (accountId == null || session == null || currentMailboxState == null || - newState == null) { + currentMailboxState == newState) { _newFolderId = null; return; } @@ -536,11 +536,6 @@ class MailboxController extends BaseMailboxController Future _handleWebSocketMessage(WebSocketMessage message) async { try { - if (currentMailboxState == message.newState) { - log('MailboxController::_handleWebSocketMessage:Skipping redundant state: ${message.newState}'); - return Future.value(); - } - final refreshViewState = await refreshAllMailboxInteractor!.execute( session!, accountId!, 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 0840517a6..5518e06c4 100644 --- a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart +++ b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart @@ -136,12 +136,6 @@ import 'package:tmail_ui_user/features/manage_account/presentation/model/account import 'package:tmail_ui_user/features/manage_account/presentation/model/manage_account_arguments.dart'; import 'package:tmail_ui_user/features/network_connection/presentation/network_connection_controller.dart' if (dart.library.html) 'package:tmail_ui_user/features/network_connection/presentation/web_network_connection_controller.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/state/get_email_state_to_refresh_state.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_mailbox_state_to_refresh_interactor.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_email_state_to_refresh_interactor.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_mailbox_state_to_refresh_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/presentation/controller/web_socket_controller.dart'; import 'package:tmail_ui_user/features/push_notification/presentation/notification/local_notification_manager.dart'; import 'package:tmail_ui_user/features/push_notification/presentation/services/fcm_service.dart'; @@ -232,10 +226,6 @@ class MailboxDashBoardController extends ReloadableController GetAllVacationInteractor? _getAllVacationInteractor; UpdateVacationInteractor? _updateVacationInteractor; - GetEmailStateToRefreshInteractor? _getEmailStateToRefreshInteractor; - DeleteEmailStateToRefreshInteractor? _deleteEmailStateToRefreshInteractor; - GetMailboxStateToRefreshInteractor? _getMailboxStateToRefreshInteractor; - DeleteMailboxStateToRefreshInteractor? _deleteMailboxStateToRefreshInteractor; GetAutoCompleteInteractor? _getAutoCompleteInteractor; IOSNotificationManager? _iosNotificationManager; GetServerSettingInteractor? getServerSettingInteractor; @@ -386,12 +376,6 @@ class MailboxDashBoardController extends ReloadableController AppLocalizations.of(currentContext!).your_email_being_sent, leadingSVGIcon: imagePaths.icSendToast); } - } else if (success is GetEmailStateToRefreshSuccess) { - dispatchEmailUIAction(RefreshChangeEmailAction(success.storedState)); - _deleteEmailStateToRefreshAction(); - } else if (success is GetMailboxStateToRefreshSuccess) { - dispatchMailboxUIAction(RefreshChangeMailboxAction(success.storedState)); - _deleteMailboxStateToRefreshAction(); } else if (success is SendEmailSuccess) { _handleSendEmailSuccess(success); } else if (success is SaveEmailAsDraftsSuccess) { @@ -1877,7 +1861,9 @@ class MailboxDashBoardController extends ReloadableController if (result is Tuple2) { if (result.value1 is VacationResponse) { vacationResponse.value = result.value1; - dispatchMailboxUIAction(RefreshChangeMailboxAction(null)); + dispatchMailboxUIAction(RefreshChangeMailboxAction( + newState: jmap.State('vacation-updated-state'), + )); } await Future.delayed( const Duration(milliseconds: 500), @@ -1943,7 +1929,9 @@ class MailboxDashBoardController extends ReloadableController if (result is Tuple2) { if (result.value1 is VacationResponse) { vacationResponse.value = result.value1; - dispatchMailboxUIAction(RefreshChangeMailboxAction(null)); + dispatchMailboxUIAction(RefreshChangeMailboxAction( + newState: jmap.State('vacation-updated-state'), + )); } await Future.delayed( const Duration(milliseconds: 500), @@ -2176,42 +2164,12 @@ class MailboxDashBoardController extends ReloadableController void _handleRefreshActionWhenBackToApp(RefreshActionViewEvent viewEvent) { log('MailboxDashBoardController::_handleRefreshActionWhenBackToApp():'); - try { - _getEmailStateToRefreshInteractor = getBinding(); - _getMailboxStateToRefreshInteractor = getBinding(); - } catch (e) { - logError('MailboxDashBoardController::_handleRefreshActionWhenBackToApp(): $e'); - } - if (_getEmailStateToRefreshInteractor != null && accountId.value != null && sessionCurrent != null) { - consumeState(_getEmailStateToRefreshInteractor!.execute(accountId.value!, sessionCurrent!.username)); - } - if (_getMailboxStateToRefreshInteractor != null && accountId.value != null && sessionCurrent != null) { - consumeState(_getMailboxStateToRefreshInteractor!.execute(accountId.value!, sessionCurrent!.username)); - } - } - - void _deleteEmailStateToRefreshAction() { - log('MailboxDashBoardController::_deleteEmailStateToRefreshAction():'); - try { - _deleteEmailStateToRefreshInteractor = getBinding(); - } catch (e) { - logError('MailboxDashBoardController::_deleteEmailStateToRefreshAction(): $e'); - } - if (_deleteEmailStateToRefreshInteractor != null && accountId.value != null && sessionCurrent != null) { - consumeState(_deleteEmailStateToRefreshInteractor!.execute(accountId.value!, sessionCurrent!.username)); - } - } - - void _deleteMailboxStateToRefreshAction() { - log('MailboxDashBoardController::_deleteMailboxStateToRefreshAction():'); - try { - _deleteMailboxStateToRefreshInteractor = getBinding(); - } catch (e) { - logError('MailboxDashBoardController::_deleteMailboxStateToRefreshAction(): $e'); - } - if (_deleteMailboxStateToRefreshInteractor != null && accountId.value != null && sessionCurrent != null) { - consumeState(_deleteMailboxStateToRefreshInteractor!.execute(accountId.value!, sessionCurrent!.username)); - } + dispatchEmailUIAction(RefreshChangeEmailAction( + newState: jmap.State('refresh-action-when-back-to-app-state'), + )); + dispatchMailboxUIAction(RefreshChangeMailboxAction( + newState: jmap.State('refresh-action-when-back-to-app-state'), + )); } void _handleClickLocalNotificationOnForeground(NotificationResponse? response) { @@ -3029,7 +2987,9 @@ class MailboxDashBoardController extends ReloadableController void _handleGetRestoredDeletedMessageSuccess(GetRestoredDeletedMessageSuccess success) async { if (selectedMailbox.value != null && selectedMailbox.value!.isRecovered) { - dispatchEmailUIAction(RefreshChangeEmailAction(null)); + dispatchEmailUIAction(RefreshChangeEmailAction( + newState: jmap.State('restored-deleted-message-success-state'), + )); } if (success is GetRestoredDeletedMessageCompleted) { diff --git a/lib/features/push_notification/domain/state/delete_email_state_to_refresh_state.dart b/lib/features/push_notification/domain/state/delete_email_state_to_refresh_state.dart deleted file mode 100644 index da25563a6..000000000 --- a/lib/features/push_notification/domain/state/delete_email_state_to_refresh_state.dart +++ /dev/null @@ -1,18 +0,0 @@ - -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; - -class DeleteEmailStateToRefreshLoading extends UIState {} - -class DeleteEmailStateToRefreshSuccess extends UIState { - - DeleteEmailStateToRefreshSuccess(); - - @override - List get props => []; -} - -class DeleteEmailStateToRefreshFailure extends FeatureFailure { - - DeleteEmailStateToRefreshFailure(dynamic exception) : super(exception: exception); -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/state/delete_mailbox_state_to_refresh_state.dart b/lib/features/push_notification/domain/state/delete_mailbox_state_to_refresh_state.dart deleted file mode 100644 index e72c30dc9..000000000 --- a/lib/features/push_notification/domain/state/delete_mailbox_state_to_refresh_state.dart +++ /dev/null @@ -1,18 +0,0 @@ - -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; - -class DeleteMailboxStateToRefreshLoading extends UIState {} - -class DeleteMailboxStateToRefreshSuccess extends UIState { - - DeleteMailboxStateToRefreshSuccess(); - - @override - List get props => []; -} - -class DeleteMailboxStateToRefreshFailure extends FeatureFailure { - - DeleteMailboxStateToRefreshFailure(dynamic exception) : super(exception: exception); -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/state/get_email_state_to_refresh_state.dart b/lib/features/push_notification/domain/state/get_email_state_to_refresh_state.dart deleted file mode 100644 index b42787f4c..000000000 --- a/lib/features/push_notification/domain/state/get_email_state_to_refresh_state.dart +++ /dev/null @@ -1,21 +0,0 @@ - -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; -import 'package:jmap_dart_client/jmap/core/state.dart' as jmap; - -class GetEmailStateToRefreshLoading extends UIState {} - -class GetEmailStateToRefreshSuccess extends UIState { - - final jmap.State storedState; - - GetEmailStateToRefreshSuccess(this.storedState); - - @override - List get props => [storedState]; -} - -class GetEmailStateToRefreshFailure extends FeatureFailure { - - GetEmailStateToRefreshFailure(dynamic exception) : super(exception: exception); -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart b/lib/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart deleted file mode 100644 index a834137fe..000000000 --- a/lib/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart +++ /dev/null @@ -1,21 +0,0 @@ - -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; -import 'package:jmap_dart_client/jmap/core/state.dart' as jmap; - -class GetMailboxStateToRefreshLoading extends UIState {} - -class GetMailboxStateToRefreshSuccess extends UIState { - - final jmap.State storedState; - - GetMailboxStateToRefreshSuccess(this.storedState); - - @override - List get props => [storedState]; -} - -class GetMailboxStateToRefreshFailure extends FeatureFailure { - - GetMailboxStateToRefreshFailure(dynamic exception) : super(exception: exception); -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart b/lib/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart deleted file mode 100644 index 8de887300..000000000 --- a/lib/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; -import 'package:dartz/dartz.dart'; -import 'package:fcm/model/type_name.dart'; -import 'package:jmap_dart_client/jmap/account_id.dart'; -import 'package:jmap_dart_client/jmap/core/user_name.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/state/delete_email_state_to_refresh_state.dart'; - -class DeleteEmailStateToRefreshInteractor { - final FCMRepository _fcmRepository; - - DeleteEmailStateToRefreshInteractor(this._fcmRepository); - - Stream> execute(AccountId accountId, UserName userName) async* { - try { - yield Right(DeleteEmailStateToRefreshLoading()); - await _fcmRepository.deleteStateToRefresh(accountId, userName, TypeName.emailType); - yield Right(DeleteEmailStateToRefreshSuccess()); - } catch (e) { - yield Left(DeleteEmailStateToRefreshFailure(e)); - } - } -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/usecases/delete_mailbox_state_to_refresh_interactor.dart b/lib/features/push_notification/domain/usecases/delete_mailbox_state_to_refresh_interactor.dart deleted file mode 100644 index f2e8aed85..000000000 --- a/lib/features/push_notification/domain/usecases/delete_mailbox_state_to_refresh_interactor.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; -import 'package:dartz/dartz.dart'; -import 'package:fcm/model/type_name.dart'; -import 'package:jmap_dart_client/jmap/account_id.dart'; -import 'package:jmap_dart_client/jmap/core/user_name.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/state/delete_mailbox_state_to_refresh_state.dart'; - -class DeleteMailboxStateToRefreshInteractor { - final FCMRepository _fcmRepository; - - DeleteMailboxStateToRefreshInteractor(this._fcmRepository); - - Stream> execute(AccountId accountId, UserName userName) async* { - try { - yield Right(DeleteMailboxStateToRefreshLoading()); - await _fcmRepository.deleteStateToRefresh(accountId, userName, TypeName.mailboxType); - yield Right(DeleteMailboxStateToRefreshSuccess()); - } catch (e) { - yield Left(DeleteMailboxStateToRefreshFailure(e)); - } - } -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/usecases/get_email_state_to_refresh_interactor.dart b/lib/features/push_notification/domain/usecases/get_email_state_to_refresh_interactor.dart deleted file mode 100644 index 26c9c270d..000000000 --- a/lib/features/push_notification/domain/usecases/get_email_state_to_refresh_interactor.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; -import 'package:dartz/dartz.dart'; -import 'package:fcm/model/type_name.dart'; -import 'package:jmap_dart_client/jmap/account_id.dart'; -import 'package:jmap_dart_client/jmap/core/user_name.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/state/get_email_state_to_refresh_state.dart'; - -class GetEmailStateToRefreshInteractor { - final FCMRepository _fcmRepository; - - GetEmailStateToRefreshInteractor(this._fcmRepository); - - Stream> execute(AccountId accountId, UserName userName) async* { - try { - yield Right(GetEmailStateToRefreshLoading()); - final storedState = await _fcmRepository.getStateToRefresh(accountId, userName, TypeName.emailType); - yield Right(GetEmailStateToRefreshSuccess(storedState)); - } catch (e) { - yield Left(GetEmailStateToRefreshFailure(e)); - } - } -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/usecases/get_mailbox_state_to_refresh_interactor.dart b/lib/features/push_notification/domain/usecases/get_mailbox_state_to_refresh_interactor.dart deleted file mode 100644 index 30befb5bc..000000000 --- a/lib/features/push_notification/domain/usecases/get_mailbox_state_to_refresh_interactor.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; -import 'package:dartz/dartz.dart'; -import 'package:fcm/model/type_name.dart'; -import 'package:jmap_dart_client/jmap/account_id.dart'; -import 'package:jmap_dart_client/jmap/core/user_name.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart'; - -class GetMailboxStateToRefreshInteractor { - final FCMRepository _fcmRepository; - - GetMailboxStateToRefreshInteractor(this._fcmRepository); - - Stream> execute(AccountId accountId, UserName userName) async* { - try { - yield Right(GetMailboxStateToRefreshLoading()); - final storedState = await _fcmRepository.getStateToRefresh(accountId, userName, TypeName.mailboxType); - yield Right(GetMailboxStateToRefreshSuccess(storedState)); - } catch (e) { - yield Left(GetMailboxStateToRefreshFailure(e)); - } - } -} \ No newline at end of file diff --git a/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart b/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart index 7836ebd1f..ddf8e79cd 100644 --- a/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart +++ b/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart @@ -43,14 +43,11 @@ import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_ma import 'package:tmail_ui_user/features/push_notification/data/network/fcm_api.dart'; import 'package:tmail_ui_user/features/push_notification/data/repository/fcm_repository_impl.dart'; import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_firebase_registration_cache_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/destroy_firebase_registration_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_email_changes_to_push_notification_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_email_changes_to_remove_notification_interactor.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_email_state_to_refresh_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_firebase_registration_by_device_id_interactor.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_mailbox_state_to_refresh_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_mailboxes_not_put_notifications_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_new_receive_email_from_notification_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_stored_email_delivery_state_interactor.dart'; @@ -147,11 +144,8 @@ class FcmInteractorBindings extends InteractorsBindings { Get.lazyPut(() => GetEmailChangesToRemoveNotificationInteractor( Get.find(), Get.find())); - Get.lazyPut(() => GetEmailStateToRefreshInteractor(Get.find())); - Get.lazyPut(() => DeleteEmailStateToRefreshInteractor(Get.find())); Get.lazyPut(() => GetFirebaseRegistrationByDeviceIdInteractor(Get.find())); Get.lazyPut(() => RegisterNewFirebaseRegistrationTokenInteractor(Get.find())); - Get.lazyPut(() => GetMailboxStateToRefreshInteractor(Get.find())); Get.lazyPut(() => StoreFirebaseRegistrationInteractor(Get.find())); Get.lazyPut(() => GetStoredFirebaseRegistrationInteractor(Get.find())); Get.lazyPut(() => DestroyFirebaseRegistrationInteractor(Get.find())); diff --git a/lib/features/push_notification/presentation/listener/email_change_listener.dart b/lib/features/push_notification/presentation/listener/email_change_listener.dart index 860c857a4..2a82870c9 100644 --- a/lib/features/push_notification/presentation/listener/email_change_listener.dart +++ b/lib/features/push_notification/presentation/listener/email_change_listener.dart @@ -114,9 +114,9 @@ class EmailChangeListener extends ChangeListener { void _synchronizeEmailOnForegroundAction(jmap.State newState) { log('EmailChangeListener::_synchronizeEmailAction():newState: $newState'); - if (_dashBoardController != null) { - _dashBoardController!.dispatchEmailUIAction(RefreshChangeEmailAction(newState)); - } + _dashBoardController?.dispatchEmailUIAction(RefreshChangeEmailAction( + newState: newState, + )); } void _pushNotificationAction(jmap.State newState, AccountId accountId, UserName userName, Session? session) { diff --git a/lib/features/push_notification/presentation/listener/mailbox_change_listener.dart b/lib/features/push_notification/presentation/listener/mailbox_change_listener.dart index da2d4ce93..f821b8550 100644 --- a/lib/features/push_notification/presentation/listener/mailbox_change_listener.dart +++ b/lib/features/push_notification/presentation/listener/mailbox_change_listener.dart @@ -1,4 +1,3 @@ - import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/success.dart'; import 'package:core/utils/app_logger.dart'; @@ -11,18 +10,19 @@ import 'package:tmail_ui_user/features/push_notification/presentation/listener/c import 'package:tmail_ui_user/main/routes/route_navigation.dart'; class MailboxChangeListener extends ChangeListener { - MailboxDashBoardController? _dashBoardController; MailboxChangeListener._internal() { try { _dashBoardController = getBinding(); } catch (e) { - logError('MailboxChangeListener::_internal(): IS NOT REGISTERED: ${e.toString()}'); + logError( + 'MailboxChangeListener::_internal(): IS NOT REGISTERED: ${e.toString()}'); } } - static final MailboxChangeListener _instance = MailboxChangeListener._internal(); + static final MailboxChangeListener _instance = + MailboxChangeListener._internal(); static MailboxChangeListener get instance => _instance; @@ -48,8 +48,8 @@ class MailboxChangeListener extends ChangeListener { void _synchronizeMailboxOnForegroundAction(jmap.State newState) { log('MailboxChangeListener::_synchronizeMailboxOnForegroundAction():newState: $newState'); - if (_dashBoardController != null) { - _dashBoardController!.dispatchMailboxUIAction(RefreshChangeMailboxAction(newState)); - } + _dashBoardController?.dispatchMailboxUIAction(RefreshChangeMailboxAction( + newState: newState, + )); } -} \ No newline at end of file +} diff --git a/lib/features/thread/presentation/thread_controller.dart b/lib/features/thread/presentation/thread_controller.dart index d40a208b5..8d39de3db 100644 --- a/lib/features/thread/presentation/thread_controller.dart +++ b/lib/features/thread/presentation/thread_controller.dart @@ -619,12 +619,12 @@ class ThreadController extends BaseController with EmailActionController { return limit; } - void _refreshEmailChanges({jmap.State? newState}) { + void _refreshEmailChanges({required jmap.State newState}) { log('ThreadController::_refreshEmailChanges(): newState: $newState'); if (_accountId == null || _session == null || mailboxDashBoardController.currentEmailState == null || - newState == null) { + mailboxDashBoardController.currentEmailState == newState) { return; } @@ -633,12 +633,6 @@ class ThreadController extends BaseController with EmailActionController { Future _handleWebSocketMessage(WebSocketMessage message) async { try { - if (mailboxDashBoardController.currentEmailState == null || - mailboxDashBoardController.currentEmailState == message.newState) { - log('ThreadController::_handleWebSocketMessage:Skipping redundant state: ${message.newState}'); - return Future.value(); - } - if (searchController.isSearchEmailRunning) { await _refreshChangeSearchEmail(); } else { diff --git a/test/features/thread/presentation/controller/thread_controller_test.dart b/test/features/thread/presentation/controller/thread_controller_test.dart index 27064a240..417ded165 100644 --- a/test/features/thread/presentation/controller/thread_controller_test.dart +++ b/test/features/thread/presentation/controller/thread_controller_test.dart @@ -332,7 +332,7 @@ void main() { threadController.onInit(); mockMailboxDashBoardController.emailUIAction.value = - RefreshChangeEmailAction(State('new-state')); + RefreshChangeEmailAction(newState: State('new-state')); await untilCalled(mockSearchEmailInteractor.execute( any,