diff --git a/lib/features/login/data/local/account_cache_manager.dart b/lib/features/login/data/local/account_cache_manager.dart index fd027c6e3d..cf58cfd73b 100644 --- a/lib/features/login/data/local/account_cache_manager.dart +++ b/lib/features/login/data/local/account_cache_manager.dart @@ -48,4 +48,6 @@ class AccountCacheManager { log('AccountCacheManager::deleteCurrentAccount(): $hashId'); return _accountCacheClient.deleteItem(hashId); } + + Future closeAccountHiveCacheBox() => _accountCacheClient.closeBox(); } \ No newline at end of file diff --git a/lib/features/login/data/local/authentication_info_cache_manager.dart b/lib/features/login/data/local/authentication_info_cache_manager.dart index a9089267f9..6b11d8451b 100644 --- a/lib/features/login/data/local/authentication_info_cache_manager.dart +++ b/lib/features/login/data/local/authentication_info_cache_manager.dart @@ -25,4 +25,6 @@ class AuthenticationInfoCacheManager { Future removeAuthenticationInfo() { return _authenticationInfoCacheClient.deleteItem(AuthenticationInfoCache.keyCacheValue); } + + Future closeAuthenticationInfoHiveCacheBox() => _authenticationInfoCacheClient.closeBox(); } \ No newline at end of file diff --git a/lib/features/login/data/local/token_oidc_cache_manager.dart b/lib/features/login/data/local/token_oidc_cache_manager.dart index 809fe1e699..0597cc6d65 100644 --- a/lib/features/login/data/local/token_oidc_cache_manager.dart +++ b/lib/features/login/data/local/token_oidc_cache_manager.dart @@ -34,4 +34,6 @@ class TokenOidcCacheManager { log('TokenOidcCacheManager::deleteTokenOidc:'); await _tokenOidcCacheClient.clearAllData(); } + + Future closeTokenOIDCHiveCacheBox() => _tokenOidcCacheClient.closeBox(); } \ No newline at end of file diff --git a/lib/features/mailbox/data/local/state_cache_manager.dart b/lib/features/mailbox/data/local/state_cache_manager.dart index f1dd4c356b..31409a174d 100644 --- a/lib/features/mailbox/data/local/state_cache_manager.dart +++ b/lib/features/mailbox/data/local/state_cache_manager.dart @@ -24,4 +24,6 @@ class StateCacheManager { final stateKey = TupleKey(stateCache.type.name, accountId.asString, userName.value).encodeKey; return await _stateCacheClient.insertItem(stateKey, stateCache); } + + Future closeStateHiveCacheBox() => _stateCacheClient.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 9c69a7153d..8030c04626 100644 --- a/lib/features/push_notification/presentation/controller/fcm_message_controller.dart +++ b/lib/features/push_notification/presentation/controller/fcm_message_controller.dart @@ -21,10 +21,14 @@ import 'package:tmail_ui_user/features/home/domain/extensions/session_extensions import 'package:tmail_ui_user/features/home/domain/state/get_session_state.dart'; import 'package:tmail_ui_user/features/home/domain/usecases/get_session_interactor.dart'; import 'package:tmail_ui_user/features/home/presentation/home_bindings.dart'; +import 'package:tmail_ui_user/features/login/data/local/account_cache_manager.dart'; +import 'package:tmail_ui_user/features/login/data/local/authentication_info_cache_manager.dart'; +import 'package:tmail_ui_user/features/login/data/local/token_oidc_cache_manager.dart'; import 'package:tmail_ui_user/features/login/data/network/interceptors/authorization_interceptors.dart'; import 'package:tmail_ui_user/features/login/domain/state/get_credential_state.dart'; 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/data/local/state_cache_manager.dart'; import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/mailbox_dashboard_bindings.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'; @@ -48,6 +52,10 @@ class FcmMessageController extends FcmBaseController { DynamicUrlInterceptors? _dynamicUrlInterceptors; AuthorizationInterceptors? _authorizationInterceptors; GetSessionInteractor? _getSessionInteractor; + AccountCacheManager? _accountCacheManager; + TokenOidcCacheManager? _tokenOidcCacheManager; + StateCacheManager? _stateCacheManager; + AuthenticationInfoCacheManager? _authenticationInfoCacheManager; FcmMessageController._internal(); @@ -99,7 +107,7 @@ class FcmMessageController extends FcmBaseController { } } - void _handleBackgroundMessageAction(Map payloadData) async { + Future _handleBackgroundMessageAction(Map payloadData) async { log('FcmMessageController::_handleBackgroundMessageAction():payloadData: $payloadData'); final stateChange = FcmUtils.instance.convertFirebaseDataMessageToStateChange(payloadData); await _initialAppConfig(); @@ -187,6 +195,17 @@ class FcmMessageController extends FcmBaseController { }); _getInteractorBindings(); + + await Future.wait([ + if (_accountCacheManager != null) + _accountCacheManager!.closeAccountHiveCacheBox(), + if (_tokenOidcCacheManager != null) + _tokenOidcCacheManager!.closeTokenOIDCHiveCacheBox(), + if (_stateCacheManager != null) + _stateCacheManager!.closeStateHiveCacheBox(), + if (_authenticationInfoCacheManager != null) + _authenticationInfoCacheManager!.closeAuthenticationInfoHiveCacheBox(), + ]); } void _getInteractorBindings() { @@ -194,6 +213,10 @@ class FcmMessageController extends FcmBaseController { _dynamicUrlInterceptors = getBinding(); _authorizationInterceptors = getBinding(); _getSessionInteractor = getBinding(); + _accountCacheManager = getBinding(); + _tokenOidcCacheManager = getBinding(); + _stateCacheManager = getBinding(); + _authenticationInfoCacheManager = getBinding(); FcmTokenController.instance.initialBindingInteractor(); }