TF-3478 Use tag to inject composer binding

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-02-11 21:48:52 +07:00
committed by Dat H. Pham
parent 332e2af683
commit 42b5711769
3 changed files with 238 additions and 111 deletions
@@ -72,40 +72,53 @@ import 'package:uuid/uuid.dart';
class ComposerBindings extends BaseBindings { class ComposerBindings extends BaseBindings {
final String? composerId;
ComposerBindings({this.composerId});
@override @override
void bindingsDataSourceImpl() { void bindingsDataSourceImpl() {
Get.lazyPut(() => AttachmentUploadDataSourceImpl( Get.lazyPut(() => AttachmentUploadDataSourceImpl(
Get.find<FileUploader>(), Get.find<FileUploader>(tag: composerId),
Get.find<Uuid>(), Get.find<Uuid>(),
Get.find<RemoteExceptionThrower>() Get.find<RemoteExceptionThrower>(),
)); ), tag: composerId);
Get.lazyPut(() => ComposerDataSourceImpl(Get.find<DownloadClient>(), Get.find<RemoteExceptionThrower>())); Get.lazyPut(() => ComposerDataSourceImpl(
Get.lazyPut(() => ContactDataSourceImpl(Get.find<CacheExceptionThrower>())); Get.find<DownloadClient>(),
Get.find<RemoteExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => ContactDataSourceImpl(
Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => MailboxDataSourceImpl( Get.lazyPut(() => MailboxDataSourceImpl(
Get.find<MailboxAPI>(), Get.find<MailboxAPI>(),
Get.find<MailboxIsolateWorker>(), Get.find<MailboxIsolateWorker>(),
Get.find<RemoteExceptionThrower>())); Get.find<RemoteExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => MailboxCacheDataSourceImpl( Get.lazyPut(() => MailboxCacheDataSourceImpl(
Get.find<MailboxCacheManager>(), Get.find<MailboxCacheManager>(),
Get.find<CacheExceptionThrower>())); Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => EmailDataSourceImpl( Get.lazyPut(() => EmailDataSourceImpl(
Get.find<EmailAPI>(), Get.find<EmailAPI>(),
Get.find<RemoteExceptionThrower>())); Get.find<RemoteExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => HtmlDataSourceImpl( Get.lazyPut(() => HtmlDataSourceImpl(
Get.find<HtmlAnalyzer>(), Get.find<HtmlAnalyzer>(),
Get.find<CacheExceptionThrower>())); Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => StateDataSourceImpl( Get.lazyPut(() => StateDataSourceImpl(
Get.find<StateCacheManager>(), Get.find<StateCacheManager>(),
Get.find<IOSSharingManager>(), Get.find<IOSSharingManager>(),
Get.find<CacheExceptionThrower>() Get.find<CacheExceptionThrower>(),
)); ), tag: composerId);
Get.lazyPut(() => PrintFileDataSourceImpl( Get.lazyPut(() => PrintFileDataSourceImpl(
Get.find<PrintUtils>(), Get.find<PrintUtils>(),
Get.find<ImagePaths>(), Get.find<ImagePaths>(),
Get.find<FileUtils>(), Get.find<FileUtils>(),
Get.find<HtmlAnalyzer>(), Get.find<HtmlAnalyzer>(),
Get.find<CacheExceptionThrower>() Get.find<CacheExceptionThrower>(),
)); ), tag: composerId);
Get.lazyPut(() => EmailHiveCacheDataSourceImpl( Get.lazyPut(() => EmailHiveCacheDataSourceImpl(
Get.find<NewEmailCacheManager>(), Get.find<NewEmailCacheManager>(),
Get.find<OpenedEmailCacheManager>(), Get.find<OpenedEmailCacheManager>(),
@@ -114,127 +127,197 @@ class ComposerBindings extends BaseBindings {
Get.find<EmailCacheManager>(), Get.find<EmailCacheManager>(),
Get.find<SendingEmailCacheManager>(), Get.find<SendingEmailCacheManager>(),
Get.find<FileUtils>(), Get.find<FileUtils>(),
Get.find<CacheExceptionThrower>())); Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => EmailLocalStorageDataSourceImpl( Get.lazyPut(() => EmailLocalStorageDataSourceImpl(
Get.find<LocalStorageManager>(), Get.find<LocalStorageManager>(),
Get.find<CacheExceptionThrower>())); Get.find<CacheExceptionThrower>(),
), tag: composerId);
Get.lazyPut(() => EmailSessionStorageDatasourceImpl( Get.lazyPut(() => EmailSessionStorageDatasourceImpl(
Get.find<SessionStorageManager>(), Get.find<SessionStorageManager>(),
Get.find<CacheExceptionThrower>())); Get.find<CacheExceptionThrower>(),
), tag: composerId);
} }
@override @override
void bindingsDataSource() { void bindingsDataSource() {
Get.lazyPut<AttachmentUploadDataSource>(() => Get.find<AttachmentUploadDataSourceImpl>()); Get.lazyPut<AttachmentUploadDataSource>(
Get.lazyPut<ComposerDataSource>(() => Get.find<ComposerDataSourceImpl>()); () => Get.find<AttachmentUploadDataSourceImpl>(tag: composerId),
Get.lazyPut<ContactDataSource>(() => Get.find<ContactDataSourceImpl>()); tag: composerId,
Get.lazyPut<MailboxDataSource>(() => Get.find<MailboxDataSourceImpl>()); );
Get.lazyPut<EmailDataSource>(() => Get.find<EmailDataSourceImpl>()); Get.lazyPut<ComposerDataSource>(
Get.lazyPut<HtmlDataSource>(() => Get.find<HtmlDataSourceImpl>()); () => Get.find<ComposerDataSourceImpl>(tag: composerId),
Get.lazyPut<StateDataSource>(() => Get.find<StateDataSourceImpl>()); tag: composerId,
Get.lazyPut<PrintFileDataSource>(() => Get.find<PrintFileDataSourceImpl>()); );
Get.lazyPut<ContactDataSource>(
() => Get.find<ContactDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<MailboxDataSource>(
() => Get.find<MailboxDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<EmailDataSource>(
() => Get.find<EmailDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<HtmlDataSource>(
() => Get.find<HtmlDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<StateDataSource>(
() => Get.find<StateDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<PrintFileDataSource>(
() => Get.find<PrintFileDataSourceImpl>(tag: composerId),
tag: composerId,
);
} }
@override @override
void bindingsRepositoryImpl() { void bindingsRepositoryImpl() {
Get.lazyPut(() => ComposerRepositoryImpl( Get.lazyPut(() => ComposerRepositoryImpl(
Get.find<AttachmentUploadDataSource>(), Get.find<AttachmentUploadDataSource>(tag: composerId),
Get.find<ComposerDataSource>(), Get.find<ComposerDataSource>(tag: composerId),
Get.find<HtmlDataSource>(), Get.find<HtmlDataSource>(tag: composerId),
Get.find<ApplicationManager>(), Get.find<ApplicationManager>(),
Get.find<Uuid>(), Get.find<Uuid>(),
)); ), tag: composerId);
Get.lazyPut(() => ContactRepositoryImpl(Get.find<ContactDataSource>())); Get.lazyPut(
() => ContactRepositoryImpl(Get.find<ContactDataSource>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => MailboxRepositoryImpl( Get.lazyPut(() => MailboxRepositoryImpl(
{ {
DataSourceType.network: Get.find<MailboxDataSource>(), DataSourceType.network: Get.find<MailboxDataSource>(tag: composerId),
DataSourceType.local: Get.find<MailboxCacheDataSourceImpl>() DataSourceType.local: Get.find<MailboxCacheDataSourceImpl>(tag: composerId)
}, },
Get.find<StateDataSource>(), Get.find<StateDataSource>(tag: composerId),
)); ), tag: composerId);
Get.lazyPut(() => EmailRepositoryImpl( Get.lazyPut(() => EmailRepositoryImpl(
{ {
DataSourceType.network: Get.find<EmailDataSource>(), DataSourceType.network: Get.find<EmailDataSource>(tag: composerId),
DataSourceType.hiveCache: Get.find<EmailHiveCacheDataSourceImpl>(), DataSourceType.hiveCache: Get.find<EmailHiveCacheDataSourceImpl>(tag: composerId),
DataSourceType.local: Get.find<EmailLocalStorageDataSourceImpl>(), DataSourceType.local: Get.find<EmailLocalStorageDataSourceImpl>(tag: composerId),
DataSourceType.session: Get.find<EmailSessionStorageDatasourceImpl>(), DataSourceType.session: Get.find<EmailSessionStorageDatasourceImpl>(tag: composerId),
}, },
Get.find<HtmlDataSource>(), Get.find<HtmlDataSource>(tag: composerId),
Get.find<StateDataSource>(), Get.find<StateDataSource>(tag: composerId),
Get.find<PrintFileDataSource>(), Get.find<PrintFileDataSource>(tag: composerId),
)); ), tag: composerId);
} }
@override @override
void bindingsRepository() { void bindingsRepository() {
Get.lazyPut<ComposerRepository>(() => Get.find<ComposerRepositoryImpl>()); Get.lazyPut<ComposerRepository>(
Get.lazyPut<ContactRepository>(() => Get.find<ContactRepositoryImpl>()); () => Get.find<ComposerRepositoryImpl>(tag: composerId),
Get.lazyPut<MailboxRepository>(() => Get.find<MailboxRepositoryImpl>()); tag: composerId,
Get.lazyPut<EmailRepository>(() => Get.find<EmailRepositoryImpl>()); );
Get.lazyPut<ContactRepository>(
() => Get.find<ContactRepositoryImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<MailboxRepository>(
() => Get.find<MailboxRepositoryImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<EmailRepository>(
() => Get.find<EmailRepositoryImpl>(tag: composerId),
tag: composerId,
);
} }
@override @override
void bindingsInteractor() { void bindingsInteractor() {
Get.lazyPut(() => LocalFilePickerInteractor()); Get.lazyPut(
Get.lazyPut(() => LocalImagePickerInteractor()); () => LocalFilePickerInteractor(),
Get.lazyPut(() => UploadAttachmentInteractor(Get.find<ComposerRepository>())); tag: composerId,
Get.lazyPut(() => GetEmailContentInteractor(Get.find<EmailRepository>())); );
Get.lazyPut(() => RemoveComposerCacheOnWebInteractor(Get.find<ComposerCacheRepository>())); Get.lazyPut(
() => LocalImagePickerInteractor(),
tag: composerId,
);
Get.lazyPut(
() => UploadAttachmentInteractor(Get.find<ComposerRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => GetEmailContentInteractor(Get.find<EmailRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => RemoveComposerCacheOnWebInteractor(Get.find<ComposerCacheRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => SaveComposerCacheOnWebInteractor( Get.lazyPut(() => SaveComposerCacheOnWebInteractor(
Get.find<ComposerCacheRepository>(), Get.find<ComposerCacheRepository>(tag: composerId),
Get.find<ComposerRepository>(), Get.find<ComposerRepository>(tag: composerId),
)); ), tag: composerId);
Get.lazyPut(() => DownloadImageAsBase64Interactor(Get.find<ComposerRepository>())); Get.lazyPut(
Get.lazyPut(() => TransformHtmlEmailContentInteractor(Get.find<EmailRepository>())); () => DownloadImageAsBase64Interactor(Get.find<ComposerRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => TransformHtmlEmailContentInteractor(Get.find<EmailRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => CreateNewAndSendEmailInteractor( Get.lazyPut(() => CreateNewAndSendEmailInteractor(
Get.find<EmailRepository>(), Get.find<EmailRepository>(tag: composerId),
Get.find<ComposerRepository>(), Get.find<ComposerRepository>(tag: composerId),
)); ), tag: composerId);
Get.lazyPut(() => CreateNewAndSaveEmailToDraftsInteractor( Get.lazyPut(() => CreateNewAndSaveEmailToDraftsInteractor(
Get.find<EmailRepository>(), Get.find<EmailRepository>(tag: composerId),
Get.find<ComposerRepository>(), Get.find<ComposerRepository>(tag: composerId),
)); ), tag: composerId);
Get.lazyPut(() => RestoreEmailInlineImagesInteractor( Get.lazyPut(
Get.find<ComposerCacheRepository>())); () => RestoreEmailInlineImagesInteractor(Get.find<ComposerCacheRepository>(tag: composerId)),
Get.lazyPut(() => PrintEmailInteractor( tag: composerId,
Get.find<EmailRepository>())); );
Get.lazyPut(
() => PrintEmailInteractor(Get.find<EmailRepository>(tag: composerId)),
tag: composerId,
);
IdentityInteractorsBindings().dependencies(); IdentityInteractorsBindings(composerId: composerId).dependencies();
PreferencesInteractorsBindings().dependencies(); PreferencesInteractorsBindings().dependencies();
} }
@override @override
void bindingsController() { void bindingsController() {
if (PlatformInfo.isWeb) { if (PlatformInfo.isWeb) {
Get.lazyPut(() => RichTextWebController()); Get.lazyPut(() => RichTextWebController(), tag: composerId);
} else { } else {
Get.lazyPut(() => RichTextMobileTabletController()); Get.lazyPut(() => RichTextMobileTabletController(), tag: composerId);
} }
Get.lazyPut(() => UploadController(Get.find<UploadAttachmentInteractor>())); Get.lazyPut(
() => UploadController(Get.find<UploadAttachmentInteractor>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => ComposerController( Get.lazyPut(() => ComposerController(
Get.find<LocalFilePickerInteractor>(), Get.find<LocalFilePickerInteractor>(tag: composerId),
Get.find<LocalImagePickerInteractor>(), Get.find<LocalImagePickerInteractor>(tag: composerId),
Get.find<GetEmailContentInteractor>(), Get.find<GetEmailContentInteractor>(tag: composerId),
Get.find<GetAllIdentitiesInteractor>(), Get.find<GetAllIdentitiesInteractor>(tag: composerId),
Get.find<UploadController>(), Get.find<UploadController>(tag: composerId),
Get.find<RemoveComposerCacheOnWebInteractor>(), Get.find<RemoveComposerCacheOnWebInteractor>(tag: composerId),
Get.find<SaveComposerCacheOnWebInteractor>(), Get.find<SaveComposerCacheOnWebInteractor>(tag: composerId),
Get.find<DownloadImageAsBase64Interactor>(), Get.find<DownloadImageAsBase64Interactor>(tag: composerId),
Get.find<TransformHtmlEmailContentInteractor>(), Get.find<TransformHtmlEmailContentInteractor>(tag: composerId),
Get.find<GetServerSettingInteractor>(), Get.find<GetServerSettingInteractor>(tag: composerId),
Get.find<CreateNewAndSendEmailInteractor>(), Get.find<CreateNewAndSendEmailInteractor>(tag: composerId),
Get.find<CreateNewAndSaveEmailToDraftsInteractor>(), Get.find<CreateNewAndSaveEmailToDraftsInteractor>(tag: composerId),
Get.find<PrintEmailInteractor>(), Get.find<PrintEmailInteractor>(tag: composerId),
)); ), tag: composerId);
} }
void dispose() { void dispose() {
if (PlatformInfo.isWeb) { if (PlatformInfo.isWeb) {
Get.delete<RichTextWebController>(); Get.delete<RichTextWebController>(tag: composerId);
} else { } else {
Get.delete<RichTextMobileTabletController>(); Get.delete<RichTextMobileTabletController>(tag: composerId);
} }
Get.delete<UploadController>(); Get.delete<UploadController>(tag: composerId);
Get.delete<ComposerController>(); Get.delete<ComposerController>(tag: composerId);
} }
} }
@@ -28,7 +28,12 @@ import 'package:tmail_ui_user/features/composer/presentation/widgets/web/toolbar
class ComposerView extends GetWidget<ComposerController> { class ComposerView extends GetWidget<ComposerController> {
const ComposerView({Key? key}) : super(key: key); final String? composerId;
const ComposerView({super.key, this.composerId});
@override
ComposerController get controller => Get.find<ComposerController>(tag: composerId);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -24,6 +24,10 @@ import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
class IdentityInteractorsBindings extends InteractorsBindings { class IdentityInteractorsBindings extends InteractorsBindings {
final String? composerId;
IdentityInteractorsBindings({this.composerId});
@override @override
void dependencies() { void dependencies() {
_bindingsUtils(); _bindingsUtils();
@@ -32,12 +36,18 @@ class IdentityInteractorsBindings extends InteractorsBindings {
@override @override
void bindingsDataSource() { void bindingsDataSource() {
Get.lazyPut<IdentityDataSource>(() => Get.find<IdentityDataSourceImpl>()); Get.lazyPut<IdentityDataSource>(
Get.lazyPut<IdentityCreatorDataSource>(() => Get.find<LocalIdentityCreatorDataSourceImpl>()); () => Get.find<IdentityDataSourceImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<IdentityCreatorDataSource>(
() => Get.find<LocalIdentityCreatorDataSourceImpl>(tag: composerId),
tag: composerId,
);
} }
void _bindingsUtils() { void _bindingsUtils() {
Get.lazyPut(() => IdentityUtils()); Get.lazyPut(() => IdentityUtils(), tag: composerId);
} }
@override @override
@@ -45,41 +55,70 @@ class IdentityInteractorsBindings extends InteractorsBindings {
Get.lazyPut(() => IdentityDataSourceImpl( Get.lazyPut(() => IdentityDataSourceImpl(
Get.find<HtmlTransform>(), Get.find<HtmlTransform>(),
Get.find<IdentityAPI>(), Get.find<IdentityAPI>(),
Get.find<RemoteExceptionThrower>())); Get.find<RemoteExceptionThrower>()
), tag: composerId);
Get.lazyPut(() => LocalIdentityCreatorDataSourceImpl( Get.lazyPut(() => LocalIdentityCreatorDataSourceImpl(
Get.find<CacheExceptionThrower>() Get.find<CacheExceptionThrower>()
)); ), tag: composerId);
} }
@override @override
void bindingsInteractor() { void bindingsInteractor() {
Get.lazyPut(() => GetAllIdentitiesInteractor( Get.lazyPut(() => GetAllIdentitiesInteractor(
Get.find<IdentityRepository>(), Get.find<IdentityRepository>(tag: composerId),
Get.find<IdentityUtils>())); Get.find<IdentityUtils>(tag: composerId)
Get.lazyPut(() => CreateNewIdentityInteractor(Get.find<IdentityRepository>())); ), tag: composerId);
Get.lazyPut(
() => CreateNewIdentityInteractor(Get.find<IdentityRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => CreateNewDefaultIdentityInteractor( Get.lazyPut(() => CreateNewDefaultIdentityInteractor(
Get.find<IdentityRepository>(), Get.find<IdentityRepository>(tag: composerId),
Get.find<IdentityUtils>())); Get.find<IdentityUtils>(tag: composerId)
Get.lazyPut(() => DeleteIdentityInteractor(Get.find<IdentityRepository>())); ), tag: composerId);
Get.lazyPut(() => EditIdentityInteractor(Get.find<IdentityRepository>())); Get.lazyPut(
() => DeleteIdentityInteractor(Get.find<IdentityRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => EditIdentityInteractor(Get.find<IdentityRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(() => EditDefaultIdentityInteractor( Get.lazyPut(() => EditDefaultIdentityInteractor(
Get.find<IdentityRepository>(), Get.find<IdentityRepository>(tag: composerId),
Get.find<IdentityUtils>())); Get.find<IdentityUtils>(tag: composerId)
Get.lazyPut(() => TransformHtmlSignatureInteractor(Get.find<IdentityRepository>())); ), tag: composerId);
Get.lazyPut(() => SaveIdentityCacheOnWebInteractor(Get.find<IdentityCreatorRepository>())); Get.lazyPut(
() => TransformHtmlSignatureInteractor(Get.find<IdentityRepository>(tag: composerId)),
tag: composerId,
);
Get.lazyPut(
() => SaveIdentityCacheOnWebInteractor(Get.find<IdentityCreatorRepository>(tag: composerId)),
tag: composerId,
);
} }
@override @override
void bindingsRepository() { void bindingsRepository() {
Get.lazyPut<IdentityRepository>(() => Get.find<IdentityRepositoryImpl>()); Get.lazyPut<IdentityRepository>(
Get.lazyPut<IdentityCreatorRepository>(() => Get.find<IdentityCreatorRepositoryImpl>()); () => Get.find<IdentityRepositoryImpl>(tag: composerId),
tag: composerId,
);
Get.lazyPut<IdentityCreatorRepository>(
() => Get.find<IdentityCreatorRepositoryImpl>(tag: composerId),
tag: composerId,
);
} }
@override @override
void bindingsRepositoryImpl() { void bindingsRepositoryImpl() {
Get.lazyPut(() => IdentityRepositoryImpl(Get.find<IdentityDataSource>())); Get.lazyPut(
Get.lazyPut(() => IdentityCreatorRepositoryImpl( () => IdentityRepositoryImpl(Get.find<IdentityDataSource>(tag: composerId)),
Get.find<IdentityCreatorDataSource>() tag: composerId,
)); );
Get.lazyPut(
() => IdentityCreatorRepositoryImpl(Get.find<IdentityCreatorDataSource>(tag: composerId)),
tag: composerId,
);
} }
} }