diff --git a/lib/features/push_notification/data/datasource_impl/cache_fcm_datasource_impl.dart b/lib/features/push_notification/data/datasource_impl/cache_fcm_datasource_impl.dart index b516744d7..f963c54de 100644 --- a/lib/features/push_notification/data/datasource_impl/cache_fcm_datasource_impl.dart +++ b/lib/features/push_notification/data/datasource_impl/cache_fcm_datasource_impl.dart @@ -28,7 +28,7 @@ class CacheFCMDatasourceImpl extends FCMDatasource { } @override - Future getStateToRefresh(AccountId accountId,UserName userName, TypeName typeName) { + Future getStateToRefresh(AccountId accountId, UserName userName, TypeName typeName) { return Future.sync(() async { return await _firebaseCacheManager.getStateToRefresh(accountId, userName, typeName); }).catchError(_exceptionThrower.throwException); diff --git a/lib/features/push_notification/data/local/fcm_cache_manager.dart b/lib/features/push_notification/data/local/fcm_cache_manager.dart index 8b2857e92..c1c5ab611 100644 --- a/lib/features/push_notification/data/local/fcm_cache_manager.dart +++ b/lib/features/push_notification/data/local/fcm_cache_manager.dart @@ -22,7 +22,7 @@ class FCMCacheManager { Future getStateToRefresh(AccountId accountId, UserName userName, TypeName typeName) async { final stateKeyCache = TupleKey(typeName.value, accountId.asString, userName.value).encodeKey; - final stateValue = await _fcmCacheClient.getItem(stateKeyCache); + final stateValue = await _fcmCacheClient.getItem(stateKeyCache, needToReopen: true); if (stateValue != null) { return jmap.State(stateValue); } else { @@ -51,7 +51,7 @@ class FCMCacheManager { } Future getStoredFirebaseRegistration() async { - final firebaseRegistration = await _firebaseRegistrationCacheClient.getItem(FirebaseRegistrationCache.keyCacheValue); + final firebaseRegistration = await _firebaseRegistrationCacheClient.getItem(FirebaseRegistrationCache.keyCacheValue, needToReopen: true); if (firebaseRegistration == null) { throw NotFoundFirebaseRegistrationCacheException(); } else { @@ -62,11 +62,4 @@ class FCMCacheManager { Future deleteFirebaseRegistration() async { await _firebaseRegistrationCacheClient.deleteItem(FirebaseRegistrationCache.keyCacheValue); } - - Future closeCacheBox() async { - await Future.wait([ - _fcmCacheClient.closeBox(), - _firebaseRegistrationCacheClient.closeBox(), - ]); - } } \ No newline at end of file diff --git a/lib/features/push_notification/presentation/controller/fcm_message_controller.dart b/lib/features/push_notification/presentation/controller/fcm_message_controller.dart index 72c427a4c..8e7c5f935 100644 --- a/lib/features/push_notification/presentation/controller/fcm_message_controller.dart +++ b/lib/features/push_notification/presentation/controller/fcm_message_controller.dart @@ -26,8 +26,6 @@ import 'package:tmail_ui_user/features/login/domain/state/get_credential_state.d import 'package:tmail_ui_user/features/login/domain/state/get_stored_token_oidc_state.dart'; import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart'; import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/mailbox_dashboard_bindings.dart'; -import 'package:tmail_ui_user/features/offline_mode/manager/new_email_cache_manager.dart'; -import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart'; import 'package:tmail_ui_user/features/push_notification/presentation/action/fcm_action.dart'; import 'package:tmail_ui_user/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart'; import 'package:tmail_ui_user/features/push_notification/presentation/controller/fcm_base_controller.dart'; @@ -51,8 +49,6 @@ class FcmMessageController extends FcmBaseController { DynamicUrlInterceptors? _dynamicUrlInterceptors; AuthorizationInterceptors? _authorizationInterceptors; GetSessionInteractor? _getSessionInteractor; - NewEmailCacheManager? _newEmailCacheManager; - FCMCacheManager? _fcmCacheManager; FcmMessageController._internal(); @@ -192,13 +188,6 @@ class FcmMessageController extends FcmBaseController { }); _getInteractorBindings(); - - await Future.wait([ - if (_newEmailCacheManager != null) - _newEmailCacheManager!.closeNewEmailHiveCacheBox(), - if (_fcmCacheManager != null) - _fcmCacheManager!.closeCacheBox(), - ]); } void _getInteractorBindings() { @@ -206,8 +195,6 @@ class FcmMessageController extends FcmBaseController { _dynamicUrlInterceptors = getBinding(); _authorizationInterceptors = getBinding(); _getSessionInteractor = getBinding(); - _newEmailCacheManager = getBinding(); - _fcmCacheManager = getBinding(); FcmTokenController.instance.initialBindingInteractor(); }