TF-2310 Don't use Hive.boxExists() to avoid creating a database without an object store in hive on some browsers (Safari/Firefox)
This commit is contained in:
@@ -162,14 +162,6 @@ abstract class HiveCacheClient<T> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> isExistTable() {
|
||||
return Future.sync(() async {
|
||||
return Hive.boxExists(tableName);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> deleteBox() {
|
||||
return Hive.deleteBoxFromDisk(tableName);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ class RecentLoginUrlCacheManager {
|
||||
RecentLoginUrlCacheManager(this._recentLoginUrlCacheClient);
|
||||
|
||||
Future<void> clean(RecentLoginUrlCleanupRule cleanupRule) async {
|
||||
final recentCacheExist = await _recentLoginUrlCacheClient.isExistTable();
|
||||
if (recentCacheExist) {
|
||||
final listRecentUrlCache = await _recentLoginUrlCacheClient.getAll();
|
||||
listRecentUrlCache.sortByCreationDate();
|
||||
|
||||
@@ -22,6 +20,5 @@ class RecentLoginUrlCacheManager {
|
||||
.toList();
|
||||
await _recentLoginUrlCacheClient.deleteMultipleItem(newListKeyRecent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,6 @@ class RecentLoginUsernameCacheManager {
|
||||
RecentLoginUsernameCacheManager(this._recentLoginUsernameCacheClient);
|
||||
|
||||
Future<void> clean(RecentLoginUsernameCleanupRule cleanupRule) async {
|
||||
final recentCacheExist = await _recentLoginUsernameCacheClient.isExistTable();
|
||||
if (recentCacheExist) {
|
||||
final listRecentUsernameCache = await _recentLoginUsernameCacheClient.getAll();
|
||||
listRecentUsernameCache.sortByCreationDate();
|
||||
|
||||
@@ -22,6 +20,5 @@ class RecentLoginUsernameCacheManager {
|
||||
.toList();
|
||||
await _recentLoginUsernameCacheClient.deleteMultipleItem(newListKeyRecent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,6 @@ class RecentSearchCacheManager {
|
||||
RecentSearchCacheManager(this._recentSearchCacheClient);
|
||||
|
||||
Future<void> clean(RecentSearchCleanupRule cleanupRule) async {
|
||||
final recentSearchCacheExist = await _recentSearchCacheClient.isExistTable();
|
||||
if (recentSearchCacheExist) {
|
||||
final listRecentSearchCache = await _recentSearchCacheClient.getAll();
|
||||
listRecentSearchCache.sortByCreationDate();
|
||||
|
||||
@@ -22,6 +20,5 @@ class RecentSearchCacheManager {
|
||||
.toList();
|
||||
await _recentSearchCacheClient.deleteMultipleItem(newListKeyRecent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,7 @@ class TokenOidcCacheManager {
|
||||
|
||||
Future<void> persistOneTokenOidc(TokenOIDC tokenOIDC) async {
|
||||
log('TokenOidcCacheManager::persistOneTokenOidc(): $tokenOIDC');
|
||||
final emailCacheExist = await _tokenOidcCacheClient.isExistTable();
|
||||
if (emailCacheExist) {
|
||||
await _tokenOidcCacheClient.clearAllData();
|
||||
}
|
||||
await _tokenOidcCacheClient.clearAllData();
|
||||
log('TokenOidcCacheManager::persistOneTokenOidc(): key: ${tokenOIDC.tokenId.uuid}');
|
||||
log('TokenOidcCacheManager::persistOneTokenOidc(): key\'s hash: ${tokenOIDC.tokenIdHash}');
|
||||
log('TokenOidcCacheManager::persistOneTokenOidc(): token: ${tokenOIDC.token}');
|
||||
|
||||
@@ -41,8 +41,7 @@ class MailboxCacheManager {
|
||||
await _mailboxCacheClient.updateMultipleItem(updatedCacheMailboxes);
|
||||
}
|
||||
|
||||
final mailboxCacheExist = await _mailboxCacheClient.isExistTable();
|
||||
if (destroyed?.isNotEmpty == true && mailboxCacheExist) {
|
||||
if (destroyed?.isNotEmpty == true) {
|
||||
final destroyedCacheMailboxes = destroyed!.toCacheKeyList(accountId, userName);
|
||||
await _mailboxCacheClient.deleteMultipleItem(destroyedCacheMailboxes);
|
||||
}
|
||||
|
||||
@@ -21,12 +21,7 @@ class StateCacheManager {
|
||||
}
|
||||
|
||||
Future<void> saveState(AccountId accountId, UserName userName, StateCache stateCache) async {
|
||||
final stateCacheExist = await _stateCacheClient.isExistTable();
|
||||
final stateKey = TupleKey(stateCache.type.name, accountId.asString, userName.value).encodeKey;
|
||||
if (stateCacheExist) {
|
||||
return await _stateCacheClient.updateItem(stateKey, stateCache);
|
||||
} else {
|
||||
return await _stateCacheClient.insertItem(stateKey, stateCache);
|
||||
}
|
||||
return await _stateCacheClient.insertItem(stateKey, stateCache);
|
||||
}
|
||||
}
|
||||
@@ -75,23 +75,19 @@ class EmailCacheManager {
|
||||
await _emailCacheClient.updateMultipleItem(updatedCacheEmails);
|
||||
}
|
||||
|
||||
final emailCacheExist = await _emailCacheClient.isExistTable();
|
||||
if (destroyed?.isNotEmpty == true && emailCacheExist) {
|
||||
if (destroyed?.isNotEmpty == true) {
|
||||
final destroyedCacheEmails = destroyed!.toCacheKeyList(accountId, userName);
|
||||
await _emailCacheClient.deleteMultipleItem(destroyedCacheEmails);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> clean(EmailCleanupRule cleanupRule) async {
|
||||
final emailCacheExist = await _emailCacheClient.isExistTable();
|
||||
if (emailCacheExist) {
|
||||
final listEmailCache = await _emailCacheClient.getAll();
|
||||
final listEmailIdCacheExpire = listEmailCache
|
||||
.where((emailCache) => emailCache.expireTimeCaching(cleanupRule))
|
||||
.map((emailCache) => emailCache.id)
|
||||
.toList();
|
||||
await _emailCacheClient.deleteMultipleItem(listEmailIdCacheExpire);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> storeEmail(AccountId accountId, UserName userName, EmailCache emailCache) {
|
||||
|
||||
Reference in New Issue
Block a user