TF-1115 Implement catch exception for HiveAccountDataSource
This commit is contained in:
@@ -88,7 +88,9 @@ class EmailBindings extends BaseBindings {
|
|||||||
Get.lazyPut(() => EmailDataSourceImpl(
|
Get.lazyPut(() => EmailDataSourceImpl(
|
||||||
Get.find<EmailAPI>(),
|
Get.find<EmailAPI>(),
|
||||||
Get.find<RemoteExceptionThrower>()));
|
Get.find<RemoteExceptionThrower>()));
|
||||||
Get.lazyPut(() => HiveAccountDatasourceImpl(Get.find<AccountCacheManager>()));
|
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
||||||
|
Get.find<AccountCacheManager>(),
|
||||||
|
Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => HtmlDataSourceImpl(
|
Get.lazyPut(() => HtmlDataSourceImpl(
|
||||||
Get.find<HtmlAnalyzer>(),
|
Get.find<HtmlAnalyzer>(),
|
||||||
Get.find<DioClient>(),
|
Get.find<DioClient>(),
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ class HomeBindings extends BaseBindings {
|
|||||||
Get.find<CacheExceptionThrower>(),
|
Get.find<CacheExceptionThrower>(),
|
||||||
));
|
));
|
||||||
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
||||||
Get.find<AccountCacheManager>()
|
Get.find<AccountCacheManager>(),
|
||||||
));
|
Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
||||||
Get.find<OIDCHttpClient>(),
|
Get.find<OIDCHttpClient>(),
|
||||||
Get.find<AuthenticationClientBase>(),
|
Get.find<AuthenticationClientBase>(),
|
||||||
|
|||||||
@@ -1,27 +1,39 @@
|
|||||||
import 'package:core/utils/app_logger.dart';
|
|
||||||
import 'package:model/account/account.dart';
|
import 'package:model/account/account.dart';
|
||||||
import 'package:tmail_ui_user/features/login/data/datasource/account_datasource.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/features/login/data/local/account_cache_manager.dart';
|
||||||
|
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||||
|
|
||||||
class HiveAccountDatasourceImpl extends AccountDatasource {
|
class HiveAccountDatasourceImpl extends AccountDatasource {
|
||||||
final AccountCacheManager _accountCacheManager;
|
|
||||||
|
|
||||||
HiveAccountDatasourceImpl(this._accountCacheManager);
|
final AccountCacheManager _accountCacheManager;
|
||||||
|
final ExceptionThrower _exceptionThrower;
|
||||||
|
|
||||||
|
HiveAccountDatasourceImpl(this._accountCacheManager, this._exceptionThrower);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Account> getCurrentAccount() {
|
Future<Account> getCurrentAccount() {
|
||||||
return _accountCacheManager.getSelectedAccount();
|
return Future.sync(() async {
|
||||||
|
return await _accountCacheManager.getSelectedAccount();
|
||||||
|
}).catchError((error) {
|
||||||
|
_exceptionThrower.throwException(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> setCurrentAccount(Account newCurrentAccount) {
|
Future<void> setCurrentAccount(Account newCurrentAccount) {
|
||||||
log('HiveAccountDatasourceImpl::setCurrentAccount(): $newCurrentAccount');
|
return Future.sync(() async {
|
||||||
log('HiveAccountDatasourceImpl::setCurrentAccount(): $_accountCacheManager');
|
return await _accountCacheManager.setSelectedAccount(newCurrentAccount);
|
||||||
return _accountCacheManager.setSelectedAccount(newCurrentAccount);
|
}).catchError((error) {
|
||||||
|
_exceptionThrower.throwException(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> deleteCurrentAccount(String accountId) {
|
Future<void> deleteCurrentAccount(String accountId) {
|
||||||
return _accountCacheManager.deleteSelectedAccount(accountId);
|
return Future.sync(() async {
|
||||||
|
return await _accountCacheManager.deleteSelectedAccount(accountId);
|
||||||
|
}).catchError((error) {
|
||||||
|
_exceptionThrower.throwException(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,7 @@ import 'package:tmail_ui_user/features/login/domain/usecases/save_login_username
|
|||||||
import 'package:tmail_ui_user/features/login/presentation/login_controller.dart';
|
import 'package:tmail_ui_user/features/login/presentation/login_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
||||||
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
|
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
|
||||||
|
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||||
|
|
||||||
class LoginBindings extends BaseBindings {
|
class LoginBindings extends BaseBindings {
|
||||||
@@ -98,8 +99,8 @@ class LoginBindings extends BaseBindings {
|
|||||||
Get.find<RemoteExceptionThrower>()
|
Get.find<RemoteExceptionThrower>()
|
||||||
));
|
));
|
||||||
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
||||||
Get.find<AccountCacheManager>()
|
Get.find<AccountCacheManager>(),
|
||||||
));
|
Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => LoginUrlDataSourceImpl(
|
Get.lazyPut(() => LoginUrlDataSourceImpl(
|
||||||
Get.find<RecentLoginUrlCacheClient>()
|
Get.find<RecentLoginUrlCacheClient>()
|
||||||
));
|
));
|
||||||
|
|||||||
+3
-1
@@ -168,7 +168,9 @@ class MailboxDashBoardBindings extends BaseBindings {
|
|||||||
Get.lazyPut(() => MailboxCacheDataSourceImpl(
|
Get.lazyPut(() => MailboxCacheDataSourceImpl(
|
||||||
Get.find<MailboxCacheManager>(),
|
Get.find<MailboxCacheManager>(),
|
||||||
Get.find<CacheExceptionThrower>()));
|
Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => HiveAccountDatasourceImpl(Get.find<AccountCacheManager>()));
|
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
||||||
|
Get.find<AccountCacheManager>(),
|
||||||
|
Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
||||||
Get.find<OIDCHttpClient>(),
|
Get.find<OIDCHttpClient>(),
|
||||||
Get.find<AuthenticationClientBase>(),
|
Get.find<AuthenticationClientBase>(),
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import 'package:tmail_ui_user/features/manage_account/presentation/manage_accoun
|
|||||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/manage_account_menu_bindings.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/menu/manage_account_menu_bindings.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/settings/settings_bindings.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/menu/settings/settings_bindings.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/profiles_bindings.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/profiles_bindings.dart';
|
||||||
|
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||||
|
|
||||||
class ManageAccountDashBoardBindings extends BaseBindings {
|
class ManageAccountDashBoardBindings extends BaseBindings {
|
||||||
@@ -61,7 +62,9 @@ class ManageAccountDashBoardBindings extends BaseBindings {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void bindingsDataSourceImpl() {
|
void bindingsDataSourceImpl() {
|
||||||
Get.lazyPut(() => HiveAccountDatasourceImpl(Get.find<AccountCacheManager>()));
|
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
||||||
|
Get.find<AccountCacheManager>(),
|
||||||
|
Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
||||||
Get.find<OIDCHttpClient>(),
|
Get.find<OIDCHttpClient>(),
|
||||||
Get.find<AuthenticationClientBase>(),
|
Get.find<AuthenticationClientBase>(),
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import 'package:tmail_ui_user/features/login/domain/usecases/get_stored_token_oi
|
|||||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/session/domain/usecases/get_session_interactor.dart';
|
import 'package:tmail_ui_user/features/session/domain/usecases/get_session_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/session/presentation/session_controller.dart';
|
import 'package:tmail_ui_user/features/session/presentation/session_controller.dart';
|
||||||
|
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||||
|
|
||||||
class SessionPageBindings extends BaseBindings {
|
class SessionPageBindings extends BaseBindings {
|
||||||
@@ -62,8 +63,8 @@ class SessionPageBindings extends BaseBindings {
|
|||||||
Get.find<RemoteExceptionThrower>(),
|
Get.find<RemoteExceptionThrower>(),
|
||||||
));
|
));
|
||||||
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
||||||
Get.find<AccountCacheManager>()
|
Get.find<AccountCacheManager>(),
|
||||||
));
|
Get.find<CacheExceptionThrower>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user