diff --git a/lib/features/mailbox_dashboard/presentation/bindings/mailbox_dashboard_bindings.dart b/lib/features/mailbox_dashboard/presentation/bindings/mailbox_dashboard_bindings.dart index 0506e50b7..4b3a8e071 100644 --- a/lib/features/mailbox_dashboard/presentation/bindings/mailbox_dashboard_bindings.dart +++ b/lib/features/mailbox_dashboard/presentation/bindings/mailbox_dashboard_bindings.dart @@ -157,7 +157,7 @@ class MailboxDashBoardBindings extends BaseBindings { Get.find(), Get.find(), Get.find())); - Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find())); + Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find(), Get.find())); Get.lazyPut(() => StateDataSourceImpl(Get.find(), Get.find())); Get.lazyPut(() => MailboxDataSourceImpl( Get.find(), diff --git a/lib/features/thread/data/datasource_impl/local_thread_datasource_impl.dart b/lib/features/thread/data/datasource_impl/local_thread_datasource_impl.dart index 8d7328ad8..7d6521b71 100644 --- a/lib/features/thread/data/datasource_impl/local_thread_datasource_impl.dart +++ b/lib/features/thread/data/datasource_impl/local_thread_datasource_impl.dart @@ -13,12 +13,14 @@ import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dar import 'package:tmail_ui_user/features/thread/data/model/email_change_response.dart'; import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart'; import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart'; +import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart'; class LocalThreadDataSourceImpl extends ThreadDataSource { final EmailCacheManager _emailCacheManager; + final ExceptionThrower _exceptionThrower; - LocalThreadDataSourceImpl(this._emailCacheManager); + LocalThreadDataSourceImpl(this._emailCacheManager, this._exceptionThrower); @override Future getAllEmail( @@ -46,20 +48,36 @@ class LocalThreadDataSourceImpl extends ThreadDataSource { } @override - Future> getAllEmailCache({MailboxId? inMailboxId, Set? sort, FilterMessageOption? filterOption, UnsignedInt? limit}) { + Future> getAllEmailCache({ + MailboxId? inMailboxId, + Set? sort, + FilterMessageOption? filterOption, + UnsignedInt? limit + }) { return Future.sync(() async { - return await _emailCacheManager.getAllEmail(inMailboxId: inMailboxId, sort: sort, filterOption: filterOption ?? FilterMessageOption.all, limit: limit); + return await _emailCacheManager.getAllEmail( + inMailboxId: inMailboxId, + sort: sort, + filterOption: filterOption ?? FilterMessageOption.all, + limit: limit); }).catchError((error) { - throw error; + _exceptionThrower.throwException(error); }); } @override - Future update({List? updated, List? created, List? destroyed}) { + Future update({ + List? updated, + List? created, + List? destroyed + }) { return Future.sync(() async { - return await _emailCacheManager.update(updated: updated, created: created, destroyed: destroyed); + return await _emailCacheManager.update( + updated: updated, + created: created, + destroyed: destroyed); }).catchError((error) { - throw error; + _exceptionThrower.throwException(error); }); } diff --git a/lib/features/thread/data/datasource_impl/thread_datasource_impl.dart b/lib/features/thread/data/datasource_impl/thread_datasource_impl.dart index a30e82f6d..2137cf8ef 100644 --- a/lib/features/thread/data/datasource_impl/thread_datasource_impl.dart +++ b/lib/features/thread/data/datasource_impl/thread_datasource_impl.dart @@ -89,7 +89,7 @@ class ThreadDataSourceImpl extends ThreadDataSource { updateDestroyedEmailCache, ); }).catchError((error) { - throw error; + _exceptionThrower.throwException(error); }); } } \ No newline at end of file diff --git a/lib/features/thread/presentation/thread_bindings.dart b/lib/features/thread/presentation/thread_bindings.dart index bc754bdf6..493c407f3 100644 --- a/lib/features/thread/presentation/thread_bindings.dart +++ b/lib/features/thread/presentation/thread_bindings.dart @@ -90,7 +90,7 @@ class ThreadBindings extends BaseBindings { Get.find(), Get.find(), Get.find())); - Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find())); + Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find(), Get.find())); Get.lazyPut(() => StateDataSourceImpl(Get.find(), Get.find())); Get.lazyPut(() => EmailDataSourceImpl( Get.find(),