Use TupleKey(ObjectKey-AccountId-UserName) to store data to hive

(cherry picked from commit e0ace535d5f3af71eb13598d92524caf2c6d9bbf)
This commit is contained in:
dab246
2023-04-27 11:03:39 +07:00
committed by Dat Vu
parent 7d0a5729b2
commit 876cc368b0
107 changed files with 562 additions and 340 deletions
@@ -1,8 +1,8 @@
import 'package:core/utils/app_logger.dart';
import 'package:model/account/account.dart';
import 'package:model/account/personal_account.dart';
import 'package:tmail_ui_user/features/caching/account_cache_client.dart';
import 'package:tmail_ui_user/features/login/data/extensions/account_cache_extensions.dart';
import 'package:tmail_ui_user/features/login/data/extensions/account_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 {
@@ -10,7 +10,7 @@ class AccountCacheManager {
AccountCacheManager(this._accountCacheClient);
Future<Account> getSelectedAccount() async {
Future<PersonalAccount> getSelectedAccount() async {
try {
final allAccounts = await _accountCacheClient.getAll();
return allAccounts.firstWhere((account) => account.isSelected)
@@ -21,7 +21,7 @@ class AccountCacheManager {
}
}
Future<void> setSelectedAccount(Account account) {
Future<void> setSelectedAccount(PersonalAccount account) {
log('AccountCacheManager::setSelectedAccount(): $_accountCacheClient');
return _accountCacheClient.insertItem(account.id, account.toCache());
}