From a3645243676989716914becc764c9ec1a1c984fe Mon Sep 17 00:00:00 2001 From: dab246 Date: Tue, 16 Aug 2022 11:03:29 +0700 Subject: [PATCH] TF-838 Update inject bindings for Interactor --- .../presentation/composer_bindings.dart | 39 +++++++++++-- .../email/presentation/email_bindings.dart | 33 ++++++++++- .../bindings/mailbox_dashboard_bindings.dart | 20 +++++-- .../thread/presentation/thread_bindings.dart | 55 ++++++++++++++++--- 4 files changed, 127 insertions(+), 20 deletions(-) diff --git a/lib/features/composer/presentation/composer_bindings.dart b/lib/features/composer/presentation/composer_bindings.dart index e7a02764b..a28d3bcc7 100644 --- a/lib/features/composer/presentation/composer_bindings.dart +++ b/lib/features/composer/presentation/composer_bindings.dart @@ -2,6 +2,7 @@ import 'package:core/core.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:get/get.dart'; import 'package:tmail_ui_user/features/base/base_bindings.dart'; +import 'package:tmail_ui_user/features/caching/state_cache_client.dart'; import 'package:tmail_ui_user/features/composer/data/datasource/composer_datasource.dart'; import 'package:tmail_ui_user/features/composer/data/datasource/contact_datasource.dart'; import 'package:tmail_ui_user/features/composer/data/datasource_impl/composer_datasource_impl.dart'; @@ -27,6 +28,16 @@ import 'package:tmail_ui_user/features/email/data/network/email_api.dart'; import 'package:tmail_ui_user/features/email/data/repository/email_repository_impl.dart'; import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart'; import 'package:tmail_ui_user/features/email/domain/usecases/get_email_content_interactor.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource/mailbox_datasource.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource/state_datasource.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/mailbox_cache_datasource_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/mailbox_datasource_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/state_datasource_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/data/local/mailbox_cache_manager.dart'; +import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_api.dart'; +import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_isolate_worker.dart'; +import 'package:tmail_ui_user/features/mailbox/data/repository/mailbox_repository_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_repository.dart'; import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/composer_cache_repository.dart'; import 'package:tmail_ui_user/features/mailbox_dashboard/domain/usecases/remove_composer_cache_on_web_interactor.dart'; import 'package:tmail_ui_user/features/mailbox_dashboard/domain/usecases/save_composer_cache_on_web_interactor.dart'; @@ -61,11 +72,14 @@ class ComposerBindings extends BaseBindings { Get.lazyPut(() => AttachmentUploadDataSourceImpl(Get.find())); Get.lazyPut(() => ComposerDataSourceImpl(Get.find())); Get.lazyPut(() => ContactDataSourceImpl()); + Get.lazyPut(() => MailboxDataSourceImpl(Get.find(), Get.find())); + Get.lazyPut(() => MailboxCacheDataSourceImpl(Get.find())); Get.lazyPut(() => EmailDataSourceImpl(Get.find())); Get.lazyPut(() => HtmlDataSourceImpl( Get.find(), Get.find() )); + Get.lazyPut(() => StateDataSourceImpl(Get.find())); Get.lazyPut(() => ManageAccountDataSourceImpl( Get.find(), Get.find())); @@ -76,8 +90,10 @@ class ComposerBindings extends BaseBindings { Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); } @@ -87,9 +103,17 @@ class ComposerBindings extends BaseBindings { Get.find(), Get.find())); Get.lazyPut(() => ContactRepositoryImpl(Get.find())); + Get.lazyPut(() => MailboxRepositoryImpl( + { + DataSourceType.network: Get.find(), + DataSourceType.local: Get.find() + }, + Get.find(), + )); Get.lazyPut(() => EmailRepositoryImpl( Get.find(), - Get.find() + Get.find(), + Get.find(), )); Get.lazyPut(() => ManageAccountRepositoryImpl(Get.find())); } @@ -98,6 +122,7 @@ class ComposerBindings extends BaseBindings { void bindingsRepository() { Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); } @@ -106,10 +131,16 @@ class ComposerBindings extends BaseBindings { void bindingsInteractor() { Get.lazyPut(() => LocalFilePickerInteractor()); Get.lazyPut(() => UploadAttachmentInteractor(Get.find())); - Get.lazyPut(() => SendEmailInteractor(Get.find())); - Get.lazyPut(() => SaveEmailAsDraftsInteractor(Get.find())); + Get.lazyPut(() => SendEmailInteractor( + Get.find(), + Get.find())); + Get.lazyPut(() => SaveEmailAsDraftsInteractor( + Get.find(), + Get.find())); Get.lazyPut(() => GetEmailContentInteractor(Get.find())); - Get.lazyPut(() => UpdateEmailDraftsInteractor(Get.find())); + Get.lazyPut(() => UpdateEmailDraftsInteractor( + Get.find(), + Get.find())); Get.lazyPut(() => GetAllIdentitiesInteractor(Get.find())); Get.lazyPut(() => RemoveComposerCacheOnWebInteractor(Get.find())); Get.lazyPut(() => SaveComposerCacheOnWebInteractor(Get.find())); diff --git a/lib/features/email/presentation/email_bindings.dart b/lib/features/email/presentation/email_bindings.dart index f7192516a..6869d914e 100644 --- a/lib/features/email/presentation/email_bindings.dart +++ b/lib/features/email/presentation/email_bindings.dart @@ -2,6 +2,7 @@ import 'package:core/core.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tmail_ui_user/features/base/base_bindings.dart'; +import 'package:tmail_ui_user/features/caching/state_cache_client.dart'; import 'package:tmail_ui_user/features/email/data/datasource/email_datasource.dart'; import 'package:tmail_ui_user/features/email/data/datasource/html_datasource.dart'; import 'package:tmail_ui_user/features/email/data/datasource_impl/email_datasource_impl.dart'; @@ -35,6 +36,16 @@ import 'package:tmail_ui_user/features/login/domain/repository/account_repositor import 'package:tmail_ui_user/features/login/domain/repository/authentication_oidc_repository.dart'; import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart'; import 'package:tmail_ui_user/features/login/domain/usecases/refresh_token_oidc_interactor.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource/mailbox_datasource.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource/state_datasource.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/mailbox_cache_datasource_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/mailbox_datasource_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/state_datasource_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/data/local/mailbox_cache_manager.dart'; +import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_api.dart'; +import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_isolate_worker.dart'; +import 'package:tmail_ui_user/features/mailbox/data/repository/mailbox_repository_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_repository.dart'; class EmailBindings extends BaseBindings { @@ -54,20 +65,25 @@ class EmailBindings extends BaseBindings { @override void bindingsDataSource() { + Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); + Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); } @override void bindingsDataSourceImpl() { + Get.lazyPut(() => MailboxDataSourceImpl(Get.find(), Get.find())); + Get.lazyPut(() => MailboxCacheDataSourceImpl(Get.find())); Get.lazyPut(() => EmailDataSourceImpl(Get.find())); Get.lazyPut(() => HiveAccountDatasourceImpl(Get.find())); Get.lazyPut(() => HtmlDataSourceImpl( Get.find(), Get.find(), )); + Get.lazyPut(() => StateDataSourceImpl(Get.find())); Get.lazyPut(() => AuthenticationOIDCDataSourceImpl( Get.find(), Get.find(), @@ -79,7 +95,9 @@ class EmailBindings extends BaseBindings { @override void bindingsInteractor() { Get.lazyPut(() => GetEmailContentInteractor(Get.find())); - Get.lazyPut(() => MarkAsEmailReadInteractor(Get.find())); + Get.lazyPut(() => MarkAsEmailReadInteractor( + Get.find(), + Get.find())); Get.lazyPut(() => DownloadAttachmentsInteractor( Get.find(), Get.find(), @@ -93,7 +111,9 @@ class EmailBindings extends BaseBindings { Get.find(), Get.find(), )); - Get.lazyPut(() => MoveToMailboxInteractor(Get.find())); + Get.lazyPut(() => MoveToMailboxInteractor( + Get.find(), + Get.find())); Get.lazyPut(() => MarkAsStarEmailInteractor(Get.find())); Get.lazyPut(() => DownloadAttachmentForWebInteractor( Get.find(), @@ -108,6 +128,7 @@ class EmailBindings extends BaseBindings { @override void bindingsRepository() { + Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); @@ -116,9 +137,17 @@ class EmailBindings extends BaseBindings { @override void bindingsRepositoryImpl() { + Get.lazyPut(() => MailboxRepositoryImpl( + { + DataSourceType.network: Get.find(), + DataSourceType.local: Get.find() + }, + Get.find(), + )); Get.lazyPut(() => EmailRepositoryImpl( Get.find(), Get.find(), + Get.find() )); Get.lazyPut(() => CredentialRepositoryImpl(Get.find())); Get.lazyPut(() => AccountRepositoryImpl(Get.find())); 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 f770f152b..7bbb33bb9 100644 --- a/lib/features/mailbox_dashboard/presentation/bindings/mailbox_dashboard_bindings.dart +++ b/lib/features/mailbox_dashboard/presentation/bindings/mailbox_dashboard_bindings.dart @@ -145,13 +145,22 @@ class MailboxDashBoardBindings extends BaseBindings { @override void bindingsInteractor() { Get.lazyPut(() => GetUserProfileInteractor(Get.find())); - Get.lazyPut(() => RemoveEmailDraftsInteractor(Get.find())); - Get.lazyPut(() => MoveToMailboxInteractor(Get.find())); - Get.lazyPut(() => DeleteEmailPermanentlyInteractor(Get.find())); + Get.lazyPut(() => RemoveEmailDraftsInteractor( + Get.find(), + Get.find())); + Get.lazyPut(() => MoveToMailboxInteractor( + Get.find(), + Get.find())); + Get.lazyPut(() => DeleteEmailPermanentlyInteractor( + Get.find(), + Get.find())); Get.lazyPut(() => SaveRecentSearchInteractor(Get.find())); Get.lazyPut(() => GetAllRecentSearchLatestInteractor(Get.find())); Get.lazyPut(() => QuickSearchEmailInteractor(Get.find())); - Get.lazyPut(() => MarkAsMailboxReadInteractor(Get.find())); + Get.lazyPut(() => MarkAsMailboxReadInteractor( + Get.find(), + Get.find()) + ); Get.lazyPut(() => LogoutOidcInteractor( Get.find(), Get.find(), @@ -188,7 +197,8 @@ class MailboxDashBoardBindings extends BaseBindings { void bindingsRepositoryImpl() { Get.lazyPut(() => EmailRepositoryImpl( Get.find(), - Get.find() + Get.find(), + Get.find(), )); Get.lazyPut(() => SearchRepositoryImpl(Get.find())); Get.lazyPut(() => ThreadRepositoryImpl( diff --git a/lib/features/thread/presentation/thread_bindings.dart b/lib/features/thread/presentation/thread_bindings.dart index 81e88dcfc..84260e4f6 100644 --- a/lib/features/thread/presentation/thread_bindings.dart +++ b/lib/features/thread/presentation/thread_bindings.dart @@ -14,8 +14,16 @@ import 'package:tmail_ui_user/features/email/domain/usecases/delete_multiple_ema import 'package:tmail_ui_user/features/email/domain/usecases/mark_as_email_read_interactor.dart'; import 'package:tmail_ui_user/features/email/domain/usecases/mark_as_star_email_interactor.dart'; import 'package:tmail_ui_user/features/email/domain/usecases/move_to_mailbox_interactor.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource/mailbox_datasource.dart'; import 'package:tmail_ui_user/features/mailbox/data/datasource/state_datasource.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/mailbox_cache_datasource_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/mailbox_datasource_impl.dart'; import 'package:tmail_ui_user/features/mailbox/data/datasource_impl/state_datasource_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/data/local/mailbox_cache_manager.dart'; +import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_api.dart'; +import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_isolate_worker.dart'; +import 'package:tmail_ui_user/features/mailbox/data/repository/mailbox_repository_impl.dart'; +import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_repository.dart'; import 'package:tmail_ui_user/features/thread/data/datasource/thread_datasource.dart'; import 'package:tmail_ui_user/features/thread/data/datasource_impl/local_thread_datasource_impl.dart'; import 'package:tmail_ui_user/features/thread/data/datasource_impl/thread_datasource_impl.dart'; @@ -57,6 +65,7 @@ class ThreadBindings extends BaseBindings { @override void bindingsDataSource() { + Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); @@ -65,6 +74,8 @@ class ThreadBindings extends BaseBindings { @override void bindingsDataSourceImpl() { + Get.lazyPut(() => MailboxDataSourceImpl(Get.find(), Get.find())); + Get.lazyPut(() => MailboxCacheDataSourceImpl(Get.find())); Get.lazyPut(() => ThreadDataSourceImpl(Get.find())); Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find())); Get.lazyPut(() => StateDataSourceImpl(Get.find())); @@ -78,30 +89,55 @@ class ThreadBindings extends BaseBindings { @override void bindingsInteractor() { Get.lazyPut(() => GetEmailsInMailboxInteractor(Get.find())); - Get.lazyPut(() => MarkAsEmailReadInteractor(Get.find())); - Get.lazyPut(() => MarkAsMultipleEmailReadInteractor(Get.find())); - Get.lazyPut(() => MoveToMailboxInteractor(Get.find())); - Get.lazyPut(() => MoveMultipleEmailToMailboxInteractor(Get.find())); + Get.lazyPut(() => MarkAsEmailReadInteractor( + Get.find(), + Get.find())); + Get.lazyPut(() => MarkAsMultipleEmailReadInteractor( + Get.find(), + Get.find())); + Get.lazyPut(() => MoveToMailboxInteractor( + Get.find(), + Get.find())); + Get.lazyPut(() => MoveMultipleEmailToMailboxInteractor( + Get.find(), + Get.find())); Get.lazyPut(() => MarkAsStarEmailInteractor(Get.find())); Get.lazyPut(() => MarkAsStarMultipleEmailInteractor(Get.find())); Get.lazyPut(() => RefreshChangesEmailsInMailboxInteractor(Get.find())); Get.lazyPut(() => LoadMoreEmailsInMailboxInteractor(Get.find())); Get.lazyPut(() => SearchEmailInteractor(Get.find())); Get.lazyPut(() => SearchMoreEmailInteractor(Get.find())); - Get.lazyPut(() => DeleteMultipleEmailsPermanentlyInteractor(Get.find())); - Get.lazyPut(() => EmptyTrashFolderInteractor(Get.find())); - Get.lazyPut(() => MarkAsEmailReadInteractor(Get.find())); - Get.lazyPut(() => MoveToMailboxInteractor(Get.find())); + Get.lazyPut(() => DeleteMultipleEmailsPermanentlyInteractor( + Get.find(), + Get.find())); + Get.lazyPut(() => EmptyTrashFolderInteractor( + Get.find(), + Get.find(), + Get.find())); + Get.lazyPut(() => MarkAsEmailReadInteractor( + Get.find(), + Get.find())); + Get.lazyPut(() => MoveToMailboxInteractor( + Get.find(), + Get.find())); } @override void bindingsRepository() { + Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); Get.lazyPut(() => Get.find()); } @override void bindingsRepositoryImpl() { + Get.lazyPut(() => MailboxRepositoryImpl( + { + DataSourceType.network: Get.find(), + DataSourceType.local: Get.find() + }, + Get.find(), + )); Get.lazyPut(() => ThreadRepositoryImpl( { DataSourceType.network: Get.find(), @@ -112,7 +148,8 @@ class ThreadBindings extends BaseBindings { )); Get.lazyPut(() => EmailRepositoryImpl( Get.find(), - Get.find() + Get.find(), + Get.find() )); } } \ No newline at end of file