Migrate Hive box To IsolatedHive box
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -2,12 +2,13 @@ import 'package:collection/collection.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:model/account/personal_account.dart';
|
||||
import 'package:tmail_ui_user/features/caching/clients/account_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/interaction/cache_manager_interaction.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/account_cache_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/list_account_cache_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/personal_account_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
||||
|
||||
class AccountCacheManager {
|
||||
class AccountCacheManager extends CacheManagerInteraction {
|
||||
final AccountCacheClient _accountCacheClient;
|
||||
|
||||
AccountCacheManager(this._accountCacheClient);
|
||||
@@ -47,4 +48,20 @@ class AccountCacheManager {
|
||||
log('AccountCacheManager::deleteCurrentAccount(): $hashId');
|
||||
return _accountCacheClient.deleteItem(hashId);
|
||||
}
|
||||
|
||||
Future<void> clear() => _accountCacheClient.clearAllData();
|
||||
|
||||
@override
|
||||
Future<void> migrateHiveToIsolatedHive() async {
|
||||
try {
|
||||
final legacyMapItems = await _accountCacheClient.getMapItems(
|
||||
isolated: false,
|
||||
);
|
||||
log('$runtimeType::migrateHiveToIsolatedHive(): Length of legacyMapItems: ${legacyMapItems.length}');
|
||||
await _accountCacheClient.insertMultipleItem(legacyMapItems);
|
||||
log('$runtimeType::migrateHiveToIsolatedHive(): ✅ Migrate Hive box "${_accountCacheClient.tableName}" → IsolatedHive DONE');
|
||||
} catch (e) {
|
||||
logError('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_accountCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user