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() {
|
Future<void> deleteBox() {
|
||||||
return Hive.deleteBoxFromDisk(tableName);
|
return Hive.deleteBoxFromDisk(tableName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ class RecentLoginUrlCacheManager {
|
|||||||
RecentLoginUrlCacheManager(this._recentLoginUrlCacheClient);
|
RecentLoginUrlCacheManager(this._recentLoginUrlCacheClient);
|
||||||
|
|
||||||
Future<void> clean(RecentLoginUrlCleanupRule cleanupRule) async {
|
Future<void> clean(RecentLoginUrlCleanupRule cleanupRule) async {
|
||||||
final recentCacheExist = await _recentLoginUrlCacheClient.isExistTable();
|
|
||||||
if (recentCacheExist) {
|
|
||||||
final listRecentUrlCache = await _recentLoginUrlCacheClient.getAll();
|
final listRecentUrlCache = await _recentLoginUrlCacheClient.getAll();
|
||||||
listRecentUrlCache.sortByCreationDate();
|
listRecentUrlCache.sortByCreationDate();
|
||||||
|
|
||||||
@@ -22,6 +20,5 @@ class RecentLoginUrlCacheManager {
|
|||||||
.toList();
|
.toList();
|
||||||
await _recentLoginUrlCacheClient.deleteMultipleItem(newListKeyRecent);
|
await _recentLoginUrlCacheClient.deleteMultipleItem(newListKeyRecent);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,6 @@ class RecentLoginUsernameCacheManager {
|
|||||||
RecentLoginUsernameCacheManager(this._recentLoginUsernameCacheClient);
|
RecentLoginUsernameCacheManager(this._recentLoginUsernameCacheClient);
|
||||||
|
|
||||||
Future<void> clean(RecentLoginUsernameCleanupRule cleanupRule) async {
|
Future<void> clean(RecentLoginUsernameCleanupRule cleanupRule) async {
|
||||||
final recentCacheExist = await _recentLoginUsernameCacheClient.isExistTable();
|
|
||||||
if (recentCacheExist) {
|
|
||||||
final listRecentUsernameCache = await _recentLoginUsernameCacheClient.getAll();
|
final listRecentUsernameCache = await _recentLoginUsernameCacheClient.getAll();
|
||||||
listRecentUsernameCache.sortByCreationDate();
|
listRecentUsernameCache.sortByCreationDate();
|
||||||
|
|
||||||
@@ -22,6 +20,5 @@ class RecentLoginUsernameCacheManager {
|
|||||||
.toList();
|
.toList();
|
||||||
await _recentLoginUsernameCacheClient.deleteMultipleItem(newListKeyRecent);
|
await _recentLoginUsernameCacheClient.deleteMultipleItem(newListKeyRecent);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,6 @@ class RecentSearchCacheManager {
|
|||||||
RecentSearchCacheManager(this._recentSearchCacheClient);
|
RecentSearchCacheManager(this._recentSearchCacheClient);
|
||||||
|
|
||||||
Future<void> clean(RecentSearchCleanupRule cleanupRule) async {
|
Future<void> clean(RecentSearchCleanupRule cleanupRule) async {
|
||||||
final recentSearchCacheExist = await _recentSearchCacheClient.isExistTable();
|
|
||||||
if (recentSearchCacheExist) {
|
|
||||||
final listRecentSearchCache = await _recentSearchCacheClient.getAll();
|
final listRecentSearchCache = await _recentSearchCacheClient.getAll();
|
||||||
listRecentSearchCache.sortByCreationDate();
|
listRecentSearchCache.sortByCreationDate();
|
||||||
|
|
||||||
@@ -22,6 +20,5 @@ class RecentSearchCacheManager {
|
|||||||
.toList();
|
.toList();
|
||||||
await _recentSearchCacheClient.deleteMultipleItem(newListKeyRecent);
|
await _recentSearchCacheClient.deleteMultipleItem(newListKeyRecent);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,10 +22,7 @@ class TokenOidcCacheManager {
|
|||||||
|
|
||||||
Future<void> persistOneTokenOidc(TokenOIDC tokenOIDC) async {
|
Future<void> persistOneTokenOidc(TokenOIDC tokenOIDC) async {
|
||||||
log('TokenOidcCacheManager::persistOneTokenOidc(): $tokenOIDC');
|
log('TokenOidcCacheManager::persistOneTokenOidc(): $tokenOIDC');
|
||||||
final emailCacheExist = await _tokenOidcCacheClient.isExistTable();
|
await _tokenOidcCacheClient.clearAllData();
|
||||||
if (emailCacheExist) {
|
|
||||||
await _tokenOidcCacheClient.clearAllData();
|
|
||||||
}
|
|
||||||
log('TokenOidcCacheManager::persistOneTokenOidc(): key: ${tokenOIDC.tokenId.uuid}');
|
log('TokenOidcCacheManager::persistOneTokenOidc(): key: ${tokenOIDC.tokenId.uuid}');
|
||||||
log('TokenOidcCacheManager::persistOneTokenOidc(): key\'s hash: ${tokenOIDC.tokenIdHash}');
|
log('TokenOidcCacheManager::persistOneTokenOidc(): key\'s hash: ${tokenOIDC.tokenIdHash}');
|
||||||
log('TokenOidcCacheManager::persistOneTokenOidc(): token: ${tokenOIDC.token}');
|
log('TokenOidcCacheManager::persistOneTokenOidc(): token: ${tokenOIDC.token}');
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ class MailboxCacheManager {
|
|||||||
await _mailboxCacheClient.updateMultipleItem(updatedCacheMailboxes);
|
await _mailboxCacheClient.updateMultipleItem(updatedCacheMailboxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
final mailboxCacheExist = await _mailboxCacheClient.isExistTable();
|
if (destroyed?.isNotEmpty == true) {
|
||||||
if (destroyed?.isNotEmpty == true && mailboxCacheExist) {
|
|
||||||
final destroyedCacheMailboxes = destroyed!.toCacheKeyList(accountId, userName);
|
final destroyedCacheMailboxes = destroyed!.toCacheKeyList(accountId, userName);
|
||||||
await _mailboxCacheClient.deleteMultipleItem(destroyedCacheMailboxes);
|
await _mailboxCacheClient.deleteMultipleItem(destroyedCacheMailboxes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,7 @@ class StateCacheManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> saveState(AccountId accountId, UserName userName, StateCache stateCache) async {
|
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;
|
final stateKey = TupleKey(stateCache.type.name, accountId.asString, userName.value).encodeKey;
|
||||||
if (stateCacheExist) {
|
return await _stateCacheClient.insertItem(stateKey, stateCache);
|
||||||
return await _stateCacheClient.updateItem(stateKey, stateCache);
|
|
||||||
} else {
|
|
||||||
return await _stateCacheClient.insertItem(stateKey, stateCache);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,23 +75,19 @@ class EmailCacheManager {
|
|||||||
await _emailCacheClient.updateMultipleItem(updatedCacheEmails);
|
await _emailCacheClient.updateMultipleItem(updatedCacheEmails);
|
||||||
}
|
}
|
||||||
|
|
||||||
final emailCacheExist = await _emailCacheClient.isExistTable();
|
if (destroyed?.isNotEmpty == true) {
|
||||||
if (destroyed?.isNotEmpty == true && emailCacheExist) {
|
|
||||||
final destroyedCacheEmails = destroyed!.toCacheKeyList(accountId, userName);
|
final destroyedCacheEmails = destroyed!.toCacheKeyList(accountId, userName);
|
||||||
await _emailCacheClient.deleteMultipleItem(destroyedCacheEmails);
|
await _emailCacheClient.deleteMultipleItem(destroyedCacheEmails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> clean(EmailCleanupRule cleanupRule) async {
|
Future<void> clean(EmailCleanupRule cleanupRule) async {
|
||||||
final emailCacheExist = await _emailCacheClient.isExistTable();
|
|
||||||
if (emailCacheExist) {
|
|
||||||
final listEmailCache = await _emailCacheClient.getAll();
|
final listEmailCache = await _emailCacheClient.getAll();
|
||||||
final listEmailIdCacheExpire = listEmailCache
|
final listEmailIdCacheExpire = listEmailCache
|
||||||
.where((emailCache) => emailCache.expireTimeCaching(cleanupRule))
|
.where((emailCache) => emailCache.expireTimeCaching(cleanupRule))
|
||||||
.map((emailCache) => emailCache.id)
|
.map((emailCache) => emailCache.id)
|
||||||
.toList();
|
.toList();
|
||||||
await _emailCacheClient.deleteMultipleItem(listEmailIdCacheExpire);
|
await _emailCacheClient.deleteMultipleItem(listEmailIdCacheExpire);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> storeEmail(AccountId accountId, UserName userName, EmailCache emailCache) {
|
Future<void> storeEmail(AccountId accountId, UserName userName, EmailCache emailCache) {
|
||||||
|
|||||||
Reference in New Issue
Block a user