TF-1810 Move all hive clients to a separate folder
(cherry picked from commit c72e16b576835b7748e20ab3e5cce5e1f505a65f)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/account_cache.dart';
|
||||
|
||||
class AccountCacheClient extends HiveCacheClient<AccountCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'AccountCache';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/authentication_info_cache.dart';
|
||||
|
||||
class AuthenticationInfoCacheClient extends HiveCacheClient<AuthenticationInfoCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'AuthenticationInfoCache';
|
||||
|
||||
@override
|
||||
bool get encryption => true;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
abstract class CacheVersionClient {
|
||||
|
||||
String get versionKey;
|
||||
|
||||
Future<bool> storeVersion(int newVersion);
|
||||
|
||||
Future<int?> getLatestVersion();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/model/email_cache.dart';
|
||||
|
||||
class EmailCacheClient extends HiveCacheClient<EmailCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'EmailCache';
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/encryption_key_cache.dart';
|
||||
|
||||
class EncryptionKeyCacheClient extends HiveCacheClient<EncryptionKeyCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'EncryptionKeyCache';
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart';
|
||||
|
||||
class FcmCacheClient extends HiveCacheClient<String> {
|
||||
|
||||
@override
|
||||
String get tableName => CachingConstants.fcmCacheBoxName;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tmail_ui_user/features/caching/clients/cache_version_client.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class HiveCacheVersionClient extends CacheVersionClient {
|
||||
|
||||
final SharedPreferences _sharedPreferences;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
HiveCacheVersionClient(this._sharedPreferences, this._exceptionThrower);
|
||||
|
||||
@override
|
||||
String get versionKey => 'HiveCacheVersion';
|
||||
|
||||
@override
|
||||
Future<int?> getLatestVersion() {
|
||||
return Future.sync(() {
|
||||
final latestVersion = _sharedPreferences.getInt(versionKey);
|
||||
return latestVersion;
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> storeVersion(int newVersion) {
|
||||
return Future.sync(() async {
|
||||
return await _sharedPreferences.setInt(versionKey, newVersion);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_cache.dart';
|
||||
|
||||
class MailboxCacheClient extends HiveCacheClient<MailboxCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'MailboxCache';
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/recent_login_url_cache.dart';
|
||||
|
||||
class RecentLoginUrlCacheClient extends HiveCacheClient<RecentLoginUrlCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'RecentLoginUrlCache';
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/recent_login_username_cache.dart';
|
||||
|
||||
class RecentLoginUsernameCacheClient extends HiveCacheClient<RecentLoginUsernameCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'RecentLoginUsernameCache';
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/data/model/recent_search_cache.dart';
|
||||
|
||||
class RecentSearchCacheClient extends HiveCacheClient<RecentSearchCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'RecentSearchCache';
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_cache.dart';
|
||||
|
||||
class StateCacheClient extends HiveCacheClient<StateCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'StateCache';
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_subscription.dart';
|
||||
|
||||
class FCMSubscriptionCacheClient extends HiveCacheClient<FCMSubscriptionCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'FCMSubscriptionCache';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/token_oidc_cache.dart';
|
||||
|
||||
class TokenOidcCacheClient extends HiveCacheClient<TokenOidcCache> {
|
||||
|
||||
@override
|
||||
String get tableName => 'TokenOidcCache';
|
||||
|
||||
@override
|
||||
bool get encryption => true;
|
||||
}
|
||||
Reference in New Issue
Block a user