import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/core/state.dart'; import 'package:jmap_dart_client/jmap/core/user_name.dart'; import 'package:tmail_ui_user/features/mailbox/data/datasource/state_datasource.dart'; import 'package:tmail_ui_user/features/mailbox/data/local/state_cache_manager.dart'; import 'package:tmail_ui_user/features/mailbox/data/model/state_cache.dart'; import 'package:tmail_ui_user/features/mailbox/data/model/state_type.dart'; import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart'; class StateDataSourceImpl extends StateDataSource { final StateCacheManager _stateCacheManager; final ExceptionThrower _exceptionThrower; StateDataSourceImpl(this._stateCacheManager, this._exceptionThrower); @override Future getState(AccountId accountId, UserName userName, StateType stateType) { return Future.sync(() async { return await _stateCacheManager.getState(accountId, userName, stateType); }).catchError(_exceptionThrower.throwException); } @override Future saveState(AccountId accountId, UserName userName, StateCache stateCache) { return Future.sync(() async { return await _stateCacheManager.saveState(accountId, userName, stateCache); }).catchError(_exceptionThrower.throwException); } }