TF-571 Injection and configuration for Hive cache
This commit is contained in:
committed by
Dat H. Pham
parent
2c156819ba
commit
8c96a486d1
@@ -1,9 +1,11 @@
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:tmail_ui_user/features/caching/account_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/email_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/mailbox_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/recent_search_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/state_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/token_oidc_cache_client.dart';
|
||||
|
||||
class CachingManager {
|
||||
|
||||
@@ -11,12 +13,16 @@ class CachingManager {
|
||||
final StateCacheClient _stateCacheClient;
|
||||
final EmailCacheClient _emailCacheClient;
|
||||
final RecentSearchCacheClient _recentSearchCacheClient;
|
||||
final TokenOidcCacheClient _tokenOidcCacheClient;
|
||||
final AccountCacheClient _accountCacheClient;
|
||||
|
||||
CachingManager(
|
||||
this._mailboxCacheClient,
|
||||
this._stateCacheClient,
|
||||
this._emailCacheClient,
|
||||
this._recentSearchCacheClient,
|
||||
this._tokenOidcCacheClient,
|
||||
this._accountCacheClient
|
||||
);
|
||||
|
||||
Future<void> clearAll() async {
|
||||
@@ -26,6 +32,8 @@ class CachingManager {
|
||||
_mailboxCacheClient.clearAllData(),
|
||||
_emailCacheClient.clearAllData(),
|
||||
_recentSearchCacheClient.clearAllData(),
|
||||
_tokenOidcCacheClient.clearAllData(),
|
||||
_accountCacheClient.clearAllData()
|
||||
]);
|
||||
} else {
|
||||
await Future.wait([
|
||||
@@ -33,6 +41,8 @@ class CachingManager {
|
||||
_mailboxCacheClient.deleteBox(),
|
||||
_emailCacheClient.deleteBox(),
|
||||
_recentSearchCacheClient.deleteBox(),
|
||||
_tokenOidcCacheClient.deleteBox(),
|
||||
_accountCacheClient.deleteBox()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'dart:io';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:path_provider/path_provider.dart' as path_provider;
|
||||
import 'package:tmail_ui_user/features/login/data/model/account_cache.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/token_oidc_cache.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_cache.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_rights_cache.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_cache.dart';
|
||||
@@ -37,5 +39,7 @@ class HiveCacheConfig {
|
||||
Hive.registerAdapter(EmailAddressHiveCacheAdapter());
|
||||
Hive.registerAdapter(EmailCacheAdapter());
|
||||
Hive.registerAdapter(RecentSearchCacheAdapter());
|
||||
Hive.registerAdapter(TokenOidcCacheAdapter());
|
||||
Hive.registerAdapter(AccountCacheAdapter());
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,6 @@ class CachingConstants {
|
||||
static const int EMAIL_CACHE_IDENTIFY = 5;
|
||||
static const int EMAIL_ADDRESS_HIVE_CACHE_IDENTIFY = 6;
|
||||
static const int RECENT_SEARCH_HIVE_CACHE_IDENTIFY = 7;
|
||||
static const int TOKEN_OIDC_HIVE_CACHE_IDENTIFY = 8;
|
||||
static const int ACCOUNT_HIVE_CACHE_IDENTIFY = 9;
|
||||
}
|
||||
Reference in New Issue
Block a user