Close hive boxes in Background (notificaiton)

This commit is contained in:
Dat PHAM HOANG
2024-07-16 16:15:31 +07:00
committed by Dat H. Pham
parent 7b5c0d5a75
commit adaab2198d
6 changed files with 47 additions and 16 deletions
@@ -28,7 +28,7 @@ class AccountCacheManager {
log('AccountCacheManager::setCurrentAccount(): $newAccount');
final newAccountCache = newAccount.toCache();
final allAccounts = await _accountCacheClient.getAll();
log('AccountCacheManager::setCurrentAccount::allAccounts(): $allAccounts');
log('AccountCacheManager::setCurrentAccount::allAccounts(): length: ${allAccounts.length}, $allAccounts');
if (allAccounts.isNotEmpty) {
final newAllAccounts = allAccounts
.unselected()
@@ -47,4 +47,6 @@ class AccountCacheManager {
log('AccountCacheManager::deleteCurrentAccount(): $hashId');
return _accountCacheClient.deleteItem(hashId);
}
Future<void> closeAccountHiveCacheBox() => _accountCacheClient.closeBox();
}
@@ -25,4 +25,6 @@ class AuthenticationInfoCacheManager {
Future<void> removeAuthenticationInfo() {
return _authenticationInfoCacheClient.deleteItem(AuthenticationInfoCache.keyCacheValue);
}
Future<void> closeAuthenticationInfoHiveCacheBox() => _authenticationInfoCacheClient.closeBox();
}
@@ -11,6 +11,7 @@ class TokenOidcCacheManager {
TokenOidcCacheManager(this._tokenOidcCacheClient);
Future<TokenOIDC> getTokenOidc(String tokenIdHash) async {
log('TokenOidcCacheManager::getTokenOidc(): tokenIdHash: $tokenIdHash');
final tokenCache = await _tokenOidcCacheClient.getItem(tokenIdHash);
log('TokenOidcCacheManager::getTokenOidc(): tokenCache: $tokenCache');
if (tokenCache == null) {
@@ -27,9 +28,12 @@ class TokenOidcCacheManager {
log('TokenOidcCacheManager::persistOneTokenOidc(): key\'s hash: ${tokenOIDC.tokenIdHash}');
log('TokenOidcCacheManager::persistOneTokenOidc(): token: ${tokenOIDC.token}');
await _tokenOidcCacheClient.insertItem(tokenOIDC.tokenIdHash, tokenOIDC.toTokenOidcCache());
log('TokenOidcCacheManager::persistOneTokenOidc(): done');
}
Future<void> deleteTokenOidc() async {
await _tokenOidcCacheClient.clearAllData();
}
Future<void> closeTokenOIDCHiveCacheBox() => _tokenOidcCacheClient.closeBox();
}