TF-2384 Store data to keychain when save new Account

Signed-off-by: dab246 <tdvu@linagora.com>
(cherry picked from commit 4d84a3354927d1c0becaf0e8e6d7cc8c54721f58)
This commit is contained in:
dab246
2023-12-24 19:24:33 +07:00
committed by Dat H. Pham
parent 940cc2f315
commit a2a1f8246f
22 changed files with 211 additions and 238 deletions
@@ -1,14 +1,21 @@
import 'package:core/utils/platform_info.dart';
import 'package:model/account/personal_account.dart';
import 'package:tmail_ui_user/features/login/data/datasource/account_datasource.dart';
import 'package:tmail_ui_user/features/login/data/local/account_cache_manager.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
import 'package:tmail_ui_user/main/utils/ios_sharing_manager.dart';
class HiveAccountDatasourceImpl extends AccountDatasource {
final AccountCacheManager _accountCacheManager;
final IOSSharingManager _iosSharingManager;
final ExceptionThrower _exceptionThrower;
HiveAccountDatasourceImpl(this._accountCacheManager, this._exceptionThrower);
HiveAccountDatasourceImpl(
this._accountCacheManager,
this._iosSharingManager,
this._exceptionThrower
);
@override
Future<PersonalAccount> getCurrentAccount() {
@@ -20,7 +27,11 @@ class HiveAccountDatasourceImpl extends AccountDatasource {
@override
Future<void> setCurrentAccount(PersonalAccount newCurrentAccount) {
return Future.sync(() async {
return await _accountCacheManager.setCurrentAccount(newCurrentAccount);
await _accountCacheManager.setCurrentAccount(newCurrentAccount);
if (PlatformInfo.isIOS) {
await _iosSharingManager.saveKeyChainSharingSession(newCurrentAccount);
}
return Future.value(null);
}).catchError(_exceptionThrower.throwException);
}