Remove store state to refresh in FCM
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
|
||||
class StoreEmailStateToRefreshLoading extends UIState {}
|
||||
|
||||
class StoreEmailStateToRefreshSuccess extends UIState {}
|
||||
|
||||
class StoreEmailStateToRefreshFailure extends FeatureFailure {
|
||||
|
||||
StoreEmailStateToRefreshFailure(dynamic exception) : super(exception: exception);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
|
||||
class StoreMailboxStateToRefreshLoading extends UIState {}
|
||||
|
||||
class StoreMailboxStateToRefreshSuccess extends UIState {}
|
||||
|
||||
class StoreMailboxStateToRefreshFailure extends FeatureFailure {
|
||||
|
||||
StoreMailboxStateToRefreshFailure(dynamic exception) : super(exception: exception);
|
||||
}
|
||||
-25
@@ -1,25 +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/state.dart' as jmap;
|
||||
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/store_email_state_to_refresh_state.dart';
|
||||
|
||||
class StoreEmailStateToRefreshInteractor {
|
||||
final FCMRepository _fcmRepository;
|
||||
|
||||
StoreEmailStateToRefreshInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, UserName userName, jmap.State newState) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(StoreEmailStateToRefreshLoading());
|
||||
await _fcmRepository.storeStateToRefresh(accountId, userName, TypeName.emailType, newState);
|
||||
yield Right<Failure, Success>(StoreEmailStateToRefreshSuccess());
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(StoreEmailStateToRefreshFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +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/state.dart' as jmap;
|
||||
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/store_mailbox_state_to_refresh_state.dart';
|
||||
|
||||
class StoreMailboxStateToRefreshInteractor {
|
||||
final FCMRepository _fcmRepository;
|
||||
|
||||
StoreMailboxStateToRefreshInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, UserName userName, jmap.State newState) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(StoreMailboxStateToRefreshLoading());
|
||||
await _fcmRepository.storeStateToRefresh(accountId, userName, TypeName.mailboxType, newState);
|
||||
yield Right<Failure, Success>(StoreMailboxStateToRefreshSuccess());
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(StoreMailboxStateToRefreshFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,9 +57,7 @@ import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_sto
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_stored_firebase_registration_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/register_new_firebase_registration_token_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';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_firebase_registration_interator.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_mailbox_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/update_firebase_registration_token_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource/thread_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource_impl/thread_datasource_impl.dart';
|
||||
@@ -149,12 +147,10 @@ class FcmInteractorBindings extends InteractorsBindings {
|
||||
Get.lazyPut(() => GetEmailChangesToRemoveNotificationInteractor(
|
||||
Get.find<FCMRepositoryImpl>(),
|
||||
Get.find<EmailRepository>()));
|
||||
Get.lazyPut(() => StoreEmailStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => GetEmailStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => DeleteEmailStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => GetFirebaseRegistrationByDeviceIdInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => RegisterNewFirebaseRegistrationTokenInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => StoreMailboxStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => GetMailboxStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => StoreFirebaseRegistrationInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => GetStoredFirebaseRegistrationInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
|
||||
@@ -39,7 +39,6 @@ import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_mai
|
||||
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';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/action/push_notification_state_change_action.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/listener/change_listener.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/notification/local_notification_manager.dart';
|
||||
@@ -52,7 +51,6 @@ class EmailChangeListener extends ChangeListener {
|
||||
StoreEmailDeliveryStateInteractor? _storeEmailDeliveryStateInteractor;
|
||||
GetEmailChangesToPushNotificationInteractor? _getEmailChangesToPushNotificationInteractor;
|
||||
GetStoredEmailStateInteractor? _getStoredEmailStateInteractor;
|
||||
StoreEmailStateToRefreshInteractor? _storeEmailStateToRefreshInteractor;
|
||||
GetMailboxesNotPutNotificationsInteractor? _getMailboxesNotPutNotificationsInteractor;
|
||||
GetEmailChangesToRemoveNotificationInteractor? _getEmailChangesToRemoveNotificationInteractor;
|
||||
GetNewReceiveEmailFromNotificationInteractor? _getNewReceiveEmailFromNotificationInteractor;
|
||||
@@ -73,7 +71,6 @@ class EmailChangeListener extends ChangeListener {
|
||||
_getStoredEmailDeliveryStateInteractor = getBinding<GetStoredEmailDeliveryStateInteractor>();
|
||||
_storeEmailDeliveryStateInteractor = getBinding<StoreEmailDeliveryStateInteractor>();
|
||||
_getEmailChangesToPushNotificationInteractor = getBinding<GetEmailChangesToPushNotificationInteractor>();
|
||||
_storeEmailStateToRefreshInteractor = getBinding<StoreEmailStateToRefreshInteractor>();
|
||||
_getMailboxesNotPutNotificationsInteractor = getBinding<GetMailboxesNotPutNotificationsInteractor>();
|
||||
_getEmailChangesToRemoveNotificationInteractor = getBinding<GetEmailChangesToRemoveNotificationInteractor>();
|
||||
_getNewReceiveEmailFromNotificationInteractor = getBinding<GetNewReceiveEmailFromNotificationInteractor>();
|
||||
@@ -111,7 +108,6 @@ class EmailChangeListener extends ChangeListener {
|
||||
if (PlatformInfo.isAndroid) {
|
||||
_handleRemoveNotificationWhenEmailMarkAsRead(action.newState, action.accountId, action.session);
|
||||
}
|
||||
_handleStoreEmailStateToRefreshAction(action.accountId, action.userName, action.newState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,15 +286,6 @@ class EmailChangeListener extends ChangeListener {
|
||||
_emailsAvailablePushNotification.clear();
|
||||
}
|
||||
|
||||
void _handleStoreEmailStateToRefreshAction(AccountId accountId, UserName userName, jmap.State newState) {
|
||||
log('EmailChangeListener::_handleStoreEmailStateToRefreshAction():newState: $newState');
|
||||
if (_storeEmailStateToRefreshInteractor != null) {
|
||||
consumeState(_storeEmailStateToRefreshInteractor!.execute(accountId, userName, newState));
|
||||
} else {
|
||||
logError('EmailChangeListener::_handleStoreEmailStateToRefreshAction():_storeEmailStateToRefreshInteractor is null');
|
||||
}
|
||||
}
|
||||
|
||||
void _handleRemoveNotificationWhenEmailMarkAsRead(jmap.State newState, AccountId accountId, Session? session) {
|
||||
if (_getEmailChangesToRemoveNotificationInteractor != null && session != null) {
|
||||
consumeState(_getEmailChangesToRemoveNotificationInteractor!.execute(
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:tmail_ui_user/features/base/action/ui_action.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/action/mailbox_ui_action.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_mailbox_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/action/push_notification_state_change_action.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/listener/change_listener.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
@@ -16,12 +13,10 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
class MailboxChangeListener extends ChangeListener {
|
||||
|
||||
MailboxDashBoardController? _dashBoardController;
|
||||
StoreMailboxStateToRefreshInteractor? _storeMailboxStateToRefreshInteractor;
|
||||
|
||||
MailboxChangeListener._internal() {
|
||||
try {
|
||||
_dashBoardController = getBinding<MailboxDashBoardController>();
|
||||
_storeMailboxStateToRefreshInteractor = getBinding<StoreMailboxStateToRefreshInteractor>();
|
||||
} catch (e) {
|
||||
logError('MailboxChangeListener::_internal(): IS NOT REGISTERED: ${e.toString()}');
|
||||
}
|
||||
@@ -37,8 +32,6 @@ class MailboxChangeListener extends ChangeListener {
|
||||
for (var action in actions) {
|
||||
if (action is SynchronizeMailboxOnForegroundAction) {
|
||||
_synchronizeMailboxOnForegroundAction(action.newState);
|
||||
} else if (action is StoreMailboxStateToRefreshAction) {
|
||||
_handleStoreMailboxStateToRefreshAction(action.accountId, action.userName, action.newState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,11 +52,4 @@ class MailboxChangeListener extends ChangeListener {
|
||||
_dashBoardController!.dispatchMailboxUIAction(RefreshChangeMailboxAction(newState));
|
||||
}
|
||||
}
|
||||
|
||||
void _handleStoreMailboxStateToRefreshAction(AccountId accountId, UserName userName, jmap.State newState) {
|
||||
log('MailboxChangeListener::_handleStoreMailboxStateToRefreshAction():newState: $newState');
|
||||
if (_storeMailboxStateToRefreshInteractor != null) {
|
||||
consumeState(_storeMailboxStateToRefreshInteractor!.execute(accountId, userName, newState));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user