diff --git a/lib/features/push_notification/domain/usecases/get_new_receive_email_from_notification_interactor.dart b/lib/features/push_notification/domain/usecases/get_new_receive_email_from_notification_interactor.dart index 4d87279a0..53d79c068 100644 --- a/lib/features/push_notification/domain/usecases/get_new_receive_email_from_notification_interactor.dart +++ b/lib/features/push_notification/domain/usecases/get_new_receive_email_from_notification_interactor.dart @@ -16,12 +16,12 @@ class GetNewReceiveEmailFromNotificationInteractor { GetNewReceiveEmailFromNotificationInteractor(this._fcmRepository, this._emailRepository); - Stream> execute( - Session session, - AccountId accountId, - UserName userName, - jmap.State newState - ) async* { + Stream> execute({ + required Session session, + required AccountId accountId, + required UserName userName, + required jmap.State newState + }) async* { try { yield Right(GetNewReceiveEmailFromNotificationLoading()); 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 d5a1d0df0..458dcb7d0 100644 --- a/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart +++ b/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart @@ -39,6 +39,7 @@ import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_fcm import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_firebase_subscription_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'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/register_new_token_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_email_delivery_state_interactor.dart'; @@ -122,6 +123,9 @@ class FcmInteractorBindings extends InteractorsBindings { Get.lazyPut(() => GetFCMSubscriptionLocalInteractor(Get.find())); Get.lazyPut(() => DestroySubscriptionInteractor(Get.find())); Get.lazyPut(() => GetMailboxesNotPutNotificationsInteractor(Get.find())); + Get.lazyPut(() => GetNewReceiveEmailFromNotificationInteractor( + Get.find(), + Get.find())); } @override 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 a3d28ebb7..410bce864 100644 --- a/lib/features/push_notification/presentation/listener/email_change_listener.dart +++ b/lib/features/push_notification/presentation/listener/email_change_listener.dart @@ -25,10 +25,12 @@ import 'package:tmail_ui_user/features/push_notification/domain/exceptions/fcm_e import 'package:tmail_ui_user/features/push_notification/domain/state/get_email_changes_to_push_notification_state.dart'; import 'package:tmail_ui_user/features/push_notification/domain/state/get_email_changes_to_remove_notification_state.dart'; import 'package:tmail_ui_user/features/push_notification/domain/state/get_mailboxes_not_put_notifications_state.dart'; +import 'package:tmail_ui_user/features/push_notification/domain/state/get_new_receive_email_from_notification_state.dart'; import 'package:tmail_ui_user/features/push_notification/domain/state/get_stored_email_delivery_state.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_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'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_email_delivery_state_interactor.dart'; import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_email_state_to_refresh_interactor.dart'; @@ -51,6 +53,7 @@ class EmailChangeListener extends ChangeListener { StoreEmailStateToRefreshInteractor? _storeEmailStateToRefreshInteractor; GetMailboxesNotPutNotificationsInteractor? _getMailboxesNotPutNotificationsInteractor; GetEmailChangesToRemoveNotificationInteractor? _getEmailChangesToRemoveNotificationInteractor; + GetNewReceiveEmailFromNotificationInteractor? _getNewReceiveEmailFromNotificationInteractor; jmap.State? _newStateEmailDelivery; AccountId? _accountId; @@ -68,6 +71,7 @@ class EmailChangeListener extends ChangeListener { _storeEmailStateToRefreshInteractor = getBinding(); _getMailboxesNotPutNotificationsInteractor = getBinding(); _getEmailChangesToRemoveNotificationInteractor = getBinding(); + _getNewReceiveEmailFromNotificationInteractor = getBinding(); } catch (e) { logError('EmailChangeListener::_internal(): IS NOT REGISTERED: ${e.toString()}'); } @@ -86,6 +90,7 @@ class EmailChangeListener extends ChangeListener { _handleRemoveNotificationWhenEmailMarkAsRead(action.newState, action.accountId, action.session); } _synchronizeEmailOnForegroundAction(action.newState); + _getNewReceiveEmailFromNotificationAction(action.session, action.accountId, action.newState); } else if (action is PushNotificationAction) { _pushNotificationAction(action.newState, action.accountId, action.userName, action.session); } else if (action is StoreEmailStateToRefreshAction) { @@ -223,6 +228,8 @@ class EmailChangeListener extends ChangeListener { _handleLocalPushNotification(listEmails); } else if (success is GetEmailChangesToRemoveNotificationSuccess) { _handleRemoveLocalNotification(success.emailIds); + } else if (success is GetNewReceiveEmailFromNotificationSuccess) { + _handleGetNewReceiveEmailFromNotificationSuccess(success.emailIds); } } @@ -277,4 +284,19 @@ class EmailChangeListener extends ChangeListener { await Future.wait(emailIds.map((emailId) => LocalNotificationManager.instance.removeNotification(emailId.id.value))); LocalNotificationManager.instance.removeGroupPushNotification(); } + + void _getNewReceiveEmailFromNotificationAction(Session? session, AccountId accountId, jmap.State newState) { + if (_getNewReceiveEmailFromNotificationInteractor != null && session != null) { + consumeState(_getNewReceiveEmailFromNotificationInteractor!.execute( + session: session, + accountId: accountId, + userName: session.username, + newState: newState + )); + } + } + + void _handleGetNewReceiveEmailFromNotificationSuccess(List emailIds) async { + log('EmailChangeListener::_handleGetNewReceiveEmailFromNotificationSuccess():emailIds: $emailIds'); + } } \ No newline at end of file