TF-971 Implement method injectAutoCompleteBindings in all controller handle autocomplete
This commit is contained in:
@@ -74,12 +74,9 @@ abstract class BaseController extends GetxController with MessageDialogActionMix
|
||||
}
|
||||
|
||||
void injectAutoCompleteBindings(Session? session, AccountId? accountId) {
|
||||
if (session == null || accountId == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ContactAutoCompleteBindings().dependencies();
|
||||
requireCapability(session, accountId, [tmailContactCapabilityIdentifier]);
|
||||
requireCapability(session!, accountId!, [tmailContactCapabilityIdentifier]);
|
||||
TMailAutoCompleteBindings().dependencies();
|
||||
} catch (e) {
|
||||
logError('BaseController::injectAutoCompleteBindings(): exception: $e');
|
||||
|
||||
@@ -20,7 +20,6 @@ import 'package:tmail_ui_user/features/login/domain/usecases/delete_credential_i
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart';
|
||||
import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/autocomplete_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/data/local/language_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/log_out_oidc_state.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
||||
@@ -188,16 +187,12 @@ abstract class ReloadableController extends BaseController {
|
||||
newConfig: tokenOidcSuccess.oidcConfiguration);
|
||||
}
|
||||
|
||||
void injectAutoCompleteBindings() {
|
||||
AutoCompleteBindings().dependencies();
|
||||
}
|
||||
|
||||
void injectVacationBindings(Session? session, AccountId? accountId) {
|
||||
try {
|
||||
requireCapability(session!, accountId!, [CapabilityIdentifier.jmapVacationResponse]);
|
||||
VacationInteractorsBindings().dependencies();
|
||||
} catch(e) {
|
||||
logError('MailboxDashBoardController::injectVacationBindings(): exception: $e');
|
||||
logError('ReloadableController::injectVacationBindings(): exception: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
@@ -97,8 +99,8 @@ class ComposerController extends BaseController {
|
||||
final RichTextWebController richTextWebController;
|
||||
final DownloadImageAsBase64Interactor _downloadImageAsBase64Interactor;
|
||||
|
||||
late GetAutoCompleteWithDeviceContactInteractor _getAutoCompleteWithDeviceContactInteractor;
|
||||
late GetAutoCompleteInteractor _getAutoCompleteInteractor;
|
||||
GetAutoCompleteWithDeviceContactInteractor? _getAutoCompleteWithDeviceContactInteractor;
|
||||
GetAutoCompleteInteractor? _getAutoCompleteInteractor;
|
||||
|
||||
List<EmailAddress> listToEmailAddress = <EmailAddress>[];
|
||||
List<EmailAddress> listCcEmailAddress = <EmailAddress>[];
|
||||
@@ -314,6 +316,10 @@ class ComposerController extends BaseController {
|
||||
final arguments = kIsWeb ? mailboxDashBoardController.routerArguments : Get.arguments;
|
||||
if (arguments is ComposerArguments) {
|
||||
composerArguments.value = arguments;
|
||||
injectAutoCompleteBindings(
|
||||
mailboxDashBoardController.sessionCurrent,
|
||||
mailboxDashBoardController.accountId.value);
|
||||
|
||||
if (arguments.emailActionType == EmailActionType.edit) {
|
||||
_getEmailContentAction(arguments);
|
||||
}
|
||||
@@ -721,30 +727,55 @@ class ComposerController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<EmailAddress>> getAutoCompleteSuggestion(
|
||||
{required String word}) async {
|
||||
log('ComposerController::getAutoCompleteSuggestion(): $word | $_contactSuggestionSource');
|
||||
@override
|
||||
void injectAutoCompleteBindings(Session? session, AccountId? accountId) {
|
||||
try {
|
||||
super.injectAutoCompleteBindings(session, accountId);
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
} catch (e) {
|
||||
logError('ComposerController::injectAutoCompleteBindings(): $e');
|
||||
}
|
||||
}
|
||||
|
||||
if (!Get.isRegistered<GetAutoCompleteWithDeviceContactInteractor>() ||
|
||||
!Get.isRegistered<GetAutoCompleteInteractor>()) {
|
||||
mailboxDashBoardController.injectAutoCompleteBindings();
|
||||
Future<List<EmailAddress>> getAutoCompleteSuggestion(String word) async {
|
||||
log('ComposerController::getAutoCompleteSuggestion(): $word | $_contactSuggestionSource');
|
||||
try {
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
} catch (e) {
|
||||
logError('ComposerController::getAutoCompleteSuggestion(): Exception $e');
|
||||
}
|
||||
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
final accountId = mailboxDashBoardController.accountId.value;
|
||||
|
||||
if (_contactSuggestionSource == ContactSuggestionSource.all) {
|
||||
return await _getAutoCompleteWithDeviceContactInteractor
|
||||
.execute(AutoCompletePattern(word: word, accountId: mailboxDashBoardController.accountId.value))
|
||||
if (_getAutoCompleteWithDeviceContactInteractor == null || _getAutoCompleteInteractor == null) {
|
||||
return <EmailAddress>[];
|
||||
}
|
||||
|
||||
final listEmailAddress = await _getAutoCompleteWithDeviceContactInteractor!
|
||||
.execute(AutoCompletePattern(word: word, accountId: accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess ? success.listEmailAddress : <EmailAddress>[]));
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
return listEmailAddress;
|
||||
} else {
|
||||
if (_getAutoCompleteInteractor == null) {
|
||||
return <EmailAddress>[];
|
||||
}
|
||||
|
||||
final listEmailAddress = await _getAutoCompleteInteractor!
|
||||
.execute(AutoCompletePattern(word: word, accountId: accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
return listEmailAddress;
|
||||
}
|
||||
return await _getAutoCompleteInteractor
|
||||
.execute(AutoCompletePattern(word: word, accountId: mailboxDashBoardController.accountId.value))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess ? success.listEmailAddress : <EmailAddress>[]));
|
||||
}
|
||||
|
||||
void openPickAttachmentMenu(BuildContext context, List<Widget> actionTiles) {
|
||||
|
||||
@@ -298,8 +298,7 @@ class ComposerView extends GetWidget<ComposerController>
|
||||
..addOnShowFullListEmailAddressAction((prefixEmailAddress) => controller.showFullEmailAddress(prefixEmailAddress))
|
||||
..addOnAddEmailAddressTypeAction((prefixEmailAddress) => controller.addEmailAddressType(prefixEmailAddress))
|
||||
..addOnUpdateListEmailAddressAction((prefixEmailAddress, listEmailAddress) => controller.updateListEmailAddress(prefixEmailAddress, listEmailAddress))
|
||||
..addOnOpenSuggestionBoxEmailAddress(() => controller.getAutoCompleteSuggestion(word: ''))
|
||||
..addOnSuggestionEmailAddress((word) => controller.getAutoCompleteSuggestion(word: word)))
|
||||
..addOnSuggestionEmailAddress(controller.getAutoCompleteSuggestion))
|
||||
.build()
|
||||
)),
|
||||
Obx(() => controller.listEmailAddressType.contains(PrefixEmailAddress.cc) == true
|
||||
@@ -319,8 +318,7 @@ class ComposerView extends GetWidget<ComposerController>
|
||||
..addOnShowFullListEmailAddressAction((prefixEmailAddress) => controller.showFullEmailAddress(prefixEmailAddress))
|
||||
..addOnDeleteEmailAddressTypeAction((prefixEmailAddress) => controller.deleteEmailAddressType(prefixEmailAddress))
|
||||
..addOnUpdateListEmailAddressAction((prefixEmailAddress, listEmailAddress) => controller.updateListEmailAddress(prefixEmailAddress, listEmailAddress))
|
||||
..addOnOpenSuggestionBoxEmailAddress(() => controller.getAutoCompleteSuggestion(word: ''))
|
||||
..addOnSuggestionEmailAddress((word) => controller.getAutoCompleteSuggestion(word: word)))
|
||||
..addOnSuggestionEmailAddress(controller.getAutoCompleteSuggestion))
|
||||
.build())
|
||||
: const SizedBox.shrink()
|
||||
),
|
||||
@@ -341,8 +339,7 @@ class ComposerView extends GetWidget<ComposerController>
|
||||
..addOnShowFullListEmailAddressAction((prefixEmailAddress) => controller.showFullEmailAddress(prefixEmailAddress))
|
||||
..addOnDeleteEmailAddressTypeAction((prefixEmailAddress) => controller.deleteEmailAddressType(prefixEmailAddress))
|
||||
..addOnUpdateListEmailAddressAction((prefixEmailAddress, listEmailAddress) => controller.updateListEmailAddress(prefixEmailAddress, listEmailAddress))
|
||||
..addOnOpenSuggestionBoxEmailAddress(() => controller.getAutoCompleteSuggestion(word: ''))
|
||||
..addOnSuggestionEmailAddress((word) => controller.getAutoCompleteSuggestion(word: word)))
|
||||
..addOnSuggestionEmailAddress(controller.getAutoCompleteSuggestion))
|
||||
.build())
|
||||
: const SizedBox.shrink()
|
||||
),
|
||||
|
||||
@@ -421,8 +421,7 @@ class ComposerView extends GetWidget<ComposerController>
|
||||
..addOnShowFullListEmailAddressAction((prefixEmailAddress) => controller.showFullEmailAddress(prefixEmailAddress))
|
||||
..addOnAddEmailAddressTypeAction((prefixEmailAddress) => controller.addEmailAddressType(prefixEmailAddress))
|
||||
..addOnUpdateListEmailAddressAction((prefixEmailAddress, listEmailAddress) => controller.updateListEmailAddress(prefixEmailAddress, listEmailAddress))
|
||||
..addOnOpenSuggestionBoxEmailAddress(() => controller.getAutoCompleteSuggestion(word: ''))
|
||||
..addOnSuggestionEmailAddress((word) => controller.getAutoCompleteSuggestion(word: word)))
|
||||
..addOnSuggestionEmailAddress(controller.getAutoCompleteSuggestion))
|
||||
.build()
|
||||
)),
|
||||
Obx(() => controller.listEmailAddressType.contains(PrefixEmailAddress.cc) == true
|
||||
@@ -442,8 +441,7 @@ class ComposerView extends GetWidget<ComposerController>
|
||||
..addOnShowFullListEmailAddressAction((prefixEmailAddress) => controller.showFullEmailAddress(prefixEmailAddress))
|
||||
..addOnDeleteEmailAddressTypeAction((prefixEmailAddress) => controller.deleteEmailAddressType(prefixEmailAddress))
|
||||
..addOnUpdateListEmailAddressAction((prefixEmailAddress, listEmailAddress) => controller.updateListEmailAddress(prefixEmailAddress, listEmailAddress))
|
||||
..addOnOpenSuggestionBoxEmailAddress(() => controller.getAutoCompleteSuggestion(word: ''))
|
||||
..addOnSuggestionEmailAddress((word) => controller.getAutoCompleteSuggestion(word: word)))
|
||||
..addOnSuggestionEmailAddress(controller.getAutoCompleteSuggestion))
|
||||
.build())
|
||||
: const SizedBox.shrink()
|
||||
),
|
||||
@@ -464,8 +462,7 @@ class ComposerView extends GetWidget<ComposerController>
|
||||
..addOnShowFullListEmailAddressAction((prefixEmailAddress) => controller.showFullEmailAddress(prefixEmailAddress))
|
||||
..addOnDeleteEmailAddressTypeAction((prefixEmailAddress) => controller.deleteEmailAddressType(prefixEmailAddress))
|
||||
..addOnUpdateListEmailAddressAction((prefixEmailAddress, listEmailAddress) => controller.updateListEmailAddress(prefixEmailAddress, listEmailAddress))
|
||||
..addOnOpenSuggestionBoxEmailAddress(() => controller.getAutoCompleteSuggestion(word: ''))
|
||||
..addOnSuggestionEmailAddress((word) => controller.getAutoCompleteSuggestion(word: word)))
|
||||
..addOnSuggestionEmailAddress(controller.getAutoCompleteSuggestion))
|
||||
.build())
|
||||
: const SizedBox.shrink()
|
||||
),
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
import 'package:contact/contact_module.dart' as contact;
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
|
||||
extension SessionExtension on Session {
|
||||
|
||||
bool get hasSupportTmailAutoComplete =>
|
||||
capabilities.containsKey(contact.tmailContactCapabilityIdentifier);
|
||||
}
|
||||
@@ -9,17 +9,16 @@ import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/autocomplete/auto_complete_pattern.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:debounce_throttle/debounce_throttle.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/model/contact_suggestion_source.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/get_autocomplete_state.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_with_device_contact_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/session_extension.dart';
|
||||
import 'package:tmail_ui_user/features/contact/presentation/model/contact_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/autocomplete_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
class ContactController extends GetxController {
|
||||
class ContactController extends BaseController {
|
||||
|
||||
final textInputSearchController = TextEditingController();
|
||||
final textInputSearchFocus = FocusNode();
|
||||
@@ -28,8 +27,8 @@ class ContactController extends GetxController {
|
||||
final searchQuery = SearchQuery.initial().obs;
|
||||
final listContactSearched = RxList<EmailAddress>();
|
||||
|
||||
late GetAutoCompleteWithDeviceContactInteractor _getAutoCompleteWithDeviceContactInteractor;
|
||||
late GetAutoCompleteInteractor _getAutoCompleteInteractor;
|
||||
GetAutoCompleteWithDeviceContactInteractor? _getAutoCompleteWithDeviceContactInteractor;
|
||||
GetAutoCompleteInteractor? _getAutoCompleteInteractor;
|
||||
|
||||
late Debouncer<String> _deBouncerTime;
|
||||
late AccountId _accountId;
|
||||
@@ -54,6 +53,7 @@ class ContactController extends GetxController {
|
||||
if (listContactSelected.isNotEmpty) {
|
||||
contactSelected = EmailAddress(listContactSelected.first, listContactSelected.first);
|
||||
}
|
||||
injectAutoCompleteBindings(_session, _accountId);
|
||||
}
|
||||
if (!BuildUtils.isWeb) {
|
||||
Future.delayed(
|
||||
@@ -108,33 +108,52 @@ class ContactController extends GetxController {
|
||||
listContactSearched.value = listContact;
|
||||
}
|
||||
|
||||
Future<List<EmailAddress>> _getAutoCompleteSuggestion(String query) async {
|
||||
if(_session.hasSupportTmailAutoComplete != true) return <EmailAddress>[];
|
||||
@override
|
||||
void injectAutoCompleteBindings(Session? session, AccountId? accountId) {
|
||||
try {
|
||||
super.injectAutoCompleteBindings(session, accountId);
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
} catch (e) {
|
||||
logError('ContactController::injectAutoCompleteBindings(): $e');
|
||||
}
|
||||
}
|
||||
|
||||
if (!Get.isRegistered<GetAutoCompleteWithDeviceContactInteractor>() ||
|
||||
!Get.isRegistered<GetAutoCompleteInteractor>()) {
|
||||
AutoCompleteBindings().dependencies();
|
||||
Future<List<EmailAddress>> _getAutoCompleteSuggestion(String query) async {
|
||||
try {
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
} catch (e) {
|
||||
logError('ContactController::getAutoCompleteSuggestion(): Exception $e');
|
||||
}
|
||||
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
|
||||
if (_contactSuggestionSource == ContactSuggestionSource.all) {
|
||||
return await _getAutoCompleteWithDeviceContactInteractor
|
||||
if (_getAutoCompleteWithDeviceContactInteractor == null || _getAutoCompleteInteractor == null) {
|
||||
return <EmailAddress>[];
|
||||
}
|
||||
|
||||
final listEmailAddress = await _getAutoCompleteWithDeviceContactInteractor!
|
||||
.execute(AutoCompletePattern(word: query, limit: 30, accountId: _accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
return listEmailAddress;
|
||||
} else {
|
||||
if (_getAutoCompleteInteractor == null) {
|
||||
return <EmailAddress>[];
|
||||
}
|
||||
|
||||
final listEmailAddress = await _getAutoCompleteInteractor!
|
||||
.execute(AutoCompletePattern(word: query, limit: 30, accountId: _accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
return listEmailAddress;
|
||||
}
|
||||
return await _getAutoCompleteInteractor
|
||||
.execute(AutoCompletePattern(word: query, limit: 30, accountId: _accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
}
|
||||
|
||||
void selectContact(BuildContext context, EmailAddress emailAddress) {
|
||||
@@ -147,4 +166,10 @@ class ContactController extends GetxController {
|
||||
FocusScope.of(context).unfocus();
|
||||
popBack();
|
||||
}
|
||||
|
||||
@override
|
||||
void onDone() {}
|
||||
|
||||
@override
|
||||
void onError(error) {}
|
||||
}
|
||||
+6
-43
@@ -1,63 +1,26 @@
|
||||
import 'package:contact/data/datasource/auto_complete_datasource.dart';
|
||||
import 'package:contact/data/datasource_impl/tmail_contact_datasource_impl.dart';
|
||||
import 'package:contact/data/network/contact_api.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/composer/data/datasource/contact_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/composer/data/datasource_impl/contact_datasource_impl.dart';
|
||||
import 'package:tmail_ui_user/features/composer/data/repository/auto_complete_repository_impl.dart';
|
||||
import 'package:tmail_ui_user/features/composer/data/repository/contact_repository_impl.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/repository/auto_complete_repository.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/repository/contact_repository.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_with_device_contact_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/get_device_contact_suggestions_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/emails_forward_creator/presentation/emails_forward_creator_controller.dart';
|
||||
|
||||
class EmailsForwardCreatorBindings extends BaseBindings {
|
||||
|
||||
final Set<AutoCompleteDataSource> _dataSources = {};
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => EmailsForwardCreatorController(
|
||||
Get.find<GetAutoCompleteWithDeviceContactInteractor>(),
|
||||
Get.find<GetAutoCompleteInteractor>(),
|
||||
));
|
||||
Get.lazyPut(() => EmailsForwardCreatorController());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<ContactDataSource>(() => Get.find<ContactDataSourceImpl>());
|
||||
}
|
||||
void bindingsDataSource() {}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
_dataSources.clear();
|
||||
Get.lazyPut(() => ContactDataSourceImpl());
|
||||
Get.lazyPut(() => TMailContactDataSourceImpl(Get.find<ContactAPI>()));
|
||||
_dataSources.add(Get.find<TMailContactDataSourceImpl>());
|
||||
}
|
||||
void bindingsDataSourceImpl() {}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => GetDeviceContactSuggestionsInteractor(Get.find<ContactRepository>()));
|
||||
Get.lazyPut(() => GetAutoCompleteInteractor(Get.find<AutoCompleteRepository>()));
|
||||
Get.lazyPut(() => GetAutoCompleteWithDeviceContactInteractor(
|
||||
Get.find<GetAutoCompleteInteractor>(),
|
||||
Get.find<GetDeviceContactSuggestionsInteractor>()
|
||||
));
|
||||
}
|
||||
void bindingsInteractor() {}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
Get.lazyPut<ContactRepository>(() => Get.find<ContactRepositoryImpl>());
|
||||
Get.lazyPut<AutoCompleteRepository>(() => Get.find<AutoCompleteRepositoryImpl>());
|
||||
}
|
||||
void bindingsRepository() {}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
Get.lazyPut(() => ContactRepositoryImpl(Get.find<ContactDataSource>()));
|
||||
Get.lazyPut(() => AutoCompleteRepositoryImpl(_dataSources));
|
||||
}
|
||||
void bindingsRepositoryImpl() {}
|
||||
}
|
||||
+58
-37
@@ -12,8 +12,6 @@ import 'package:tmail_ui_user/features/composer/domain/model/contact_suggestion_
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/get_autocomplete_state.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_with_device_contact_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/session_extension.dart';
|
||||
import 'package:tmail_ui_user/features/emails_forward_creator/presentation/model/mails_forward_creator_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/forward/forward_controller.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
@@ -23,21 +21,20 @@ class EmailsForwardCreatorController extends BaseController {
|
||||
final ContactSuggestionSource _contactSuggestionSource = ContactSuggestionSource.tMailContact;
|
||||
final _forwardController = Get.find<ForwardController>();
|
||||
|
||||
late AccountId _accountId;
|
||||
late Session? _session;
|
||||
late GetAutoCompleteWithDeviceContactInteractor _getAutoCompleteWithDeviceContactInteractor;
|
||||
late GetAutoCompleteInteractor _getAutoCompleteInteractor;
|
||||
GetAutoCompleteWithDeviceContactInteractor? _getAutoCompleteWithDeviceContactInteractor;
|
||||
GetAutoCompleteInteractor? _getAutoCompleteInteractor;
|
||||
|
||||
final listEmailForwards = RxSet<EmailAddress>();
|
||||
|
||||
EmailsForwardCreatorController(
|
||||
this._getAutoCompleteWithDeviceContactInteractor,
|
||||
this._getAutoCompleteInteractor,
|
||||
);
|
||||
EmailsForwardCreatorController();
|
||||
|
||||
AccountId? get _accountId => _forwardController.emailsForwardCreatorArguments.value?.accountId;
|
||||
|
||||
Session? get _session => _forwardController.emailsForwardCreatorArguments.value?.session;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_getArguments();
|
||||
injectAutoCompleteBindings(_session, _accountId);
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@@ -53,35 +50,53 @@ class EmailsForwardCreatorController extends BaseController {
|
||||
@override
|
||||
void onError(error) {}
|
||||
|
||||
void _getArguments() {
|
||||
final arguments = Get.arguments;
|
||||
if (arguments is MailsForwardCreatorArguments) {
|
||||
_accountId = arguments.accountId;
|
||||
_session = arguments.session;
|
||||
@override
|
||||
void injectAutoCompleteBindings(Session? session, AccountId? accountId) {
|
||||
try {
|
||||
super.injectAutoCompleteBindings(session, accountId);
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
} catch (e) {
|
||||
logError('EmailsForwardCreatorController::injectAutoCompleteBindings(): $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<EmailAddress>> getAutoCompleteSuggestion(
|
||||
{required String word}) async {
|
||||
Future<List<EmailAddress>> getAutoCompleteSuggestion(String word) async {
|
||||
log('EmailsForwardCreatorController::getAutoCompleteSuggestion(): $word | $_contactSuggestionSource');
|
||||
|
||||
if(_session?.hasSupportTmailAutoComplete != true) return <EmailAddress>[];
|
||||
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
try {
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
} catch (e) {
|
||||
logError('EmailsForwardCreatorController::getAutoCompleteSuggestion(): Exception $e');
|
||||
}
|
||||
|
||||
if (_contactSuggestionSource == ContactSuggestionSource.all) {
|
||||
return await _getAutoCompleteWithDeviceContactInteractor
|
||||
.execute(AutoCompletePattern(word: word, accountId: _accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess ? success.listEmailAddress : <EmailAddress>[]));
|
||||
if (_getAutoCompleteWithDeviceContactInteractor == null || _getAutoCompleteInteractor == null) {
|
||||
logError('EmailsForwardCreatorController::_getAutoCompleteWithDeviceContactInteractor(): is null');
|
||||
return <EmailAddress>[];
|
||||
} else {
|
||||
return await _getAutoCompleteWithDeviceContactInteractor!
|
||||
.execute(AutoCompletePattern(word: word, accountId: _accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
}
|
||||
} else {
|
||||
if (_getAutoCompleteInteractor == null) {
|
||||
logError('EmailsForwardCreatorController::_getAutoCompleteInteractor(): is null');
|
||||
return <EmailAddress>[];
|
||||
} else {
|
||||
return await _getAutoCompleteInteractor!
|
||||
.execute(AutoCompletePattern(word: word, accountId: _accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
}
|
||||
}
|
||||
return await _getAutoCompleteInteractor
|
||||
.execute(AutoCompletePattern(word: word, accountId: _accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess ? success.listEmailAddress : <EmailAddress>[]));
|
||||
}
|
||||
|
||||
void addToListEmailForwards(EmailAddress emailAddress) {
|
||||
@@ -100,6 +115,8 @@ class EmailsForwardCreatorController extends BaseController {
|
||||
|
||||
void closeView(BuildContext context) {
|
||||
FocusScope.of(context).unfocus();
|
||||
clearAll();
|
||||
|
||||
if(kIsWeb) {
|
||||
_clearListEmailForwards();
|
||||
_forwardController.accountDashBoardController.emailsForwardCreatorIsActive.toggle();
|
||||
@@ -113,14 +130,18 @@ class EmailsForwardCreatorController extends BaseController {
|
||||
if(inputEmailForwardController.text.trim().isNotEmpty) {
|
||||
listEmailForwards.add(EmailAddress(null, inputEmailForwardController.text.trim()));
|
||||
}
|
||||
inputEmailForwardController.clear();
|
||||
clearAll();
|
||||
|
||||
if (listEmailForwards.isNotEmpty) {
|
||||
final newListEmailForwards = List<EmailAddress>.from(listEmailForwards);
|
||||
_forwardController.handleAddRecipients(newListEmailForwards);
|
||||
}
|
||||
|
||||
if(kIsWeb) {
|
||||
_forwardController.accountDashBoardController.emailsForwardCreatorIsActive.toggle();
|
||||
_forwardController.handleAddRecipients(listEmailForwards.toList());
|
||||
_clearListEmailForwards();
|
||||
_forwardController.accountDashBoardController.emailsForwardCreatorIsActive.toggle();
|
||||
} else {
|
||||
popBack(result: listEmailForwards.toList());
|
||||
popBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,12 +139,7 @@ class EmailsForwardCreatorView extends GetWidget<EmailsForwardCreatorController>
|
||||
controller.clearAll();
|
||||
}
|
||||
})
|
||||
..addOnSuggestionCallbackAction((pattern) {
|
||||
if (pattern != null) {
|
||||
controller.getAutoCompleteSuggestion(word: pattern.trim());
|
||||
}
|
||||
}))
|
||||
.build(),
|
||||
..addOnSuggestionCallbackAction(controller.getAutoCompleteSuggestion)).build(),
|
||||
),
|
||||
Expanded(
|
||||
child: Obx(() => ListView.builder(
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:tmail_ui_user/features/emails_forward_creator/presentation/widgets/emails_forward_input_decoration_builder.dart';
|
||||
|
||||
typedef OnSelectedSuggestionAction = Function(EmailAddress emailAddress);
|
||||
typedef OnSuggestionCallbackAction = Function(String? pattern);
|
||||
typedef OnSuggestionCallbackAction = Function(String pattern);
|
||||
typedef OnSummitedCallbackAction = Function(String? pattern);
|
||||
|
||||
class EmailsForwardInputWithDropListFieldBuilder {
|
||||
|
||||
+57
-25
@@ -2,9 +2,12 @@ import 'package:collection/collection.dart';
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/model/contact_suggestion_source.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/get_autocomplete_state.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_interactor.dart';
|
||||
@@ -20,9 +23,9 @@ import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
class AdvancedFilterController extends GetxController {
|
||||
late GetAutoCompleteWithDeviceContactInteractor _getAutoCompleteWithDeviceContactInteractor;
|
||||
late GetAutoCompleteInteractor _getAutoCompleteInteractor;
|
||||
class AdvancedFilterController extends BaseController {
|
||||
GetAutoCompleteWithDeviceContactInteractor? _getAutoCompleteWithDeviceContactInteractor;
|
||||
GetAutoCompleteInteractor? _getAutoCompleteInteractor;
|
||||
|
||||
final dateFilterSelectedFormAdvancedSearch = EmailReceiveTimeType.allTime.obs;
|
||||
final hasAttachment = false.obs;
|
||||
@@ -49,11 +52,15 @@ class AdvancedFilterController extends GetxController {
|
||||
final focusManager = InputFieldFocusManager.initial();
|
||||
|
||||
@override
|
||||
void onReady() async {
|
||||
void onReady() {
|
||||
if (!BuildUtils.isWeb) {
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 500), () => _checkContactPermission());
|
||||
const Duration(milliseconds: 500),
|
||||
() => _checkContactPermission());
|
||||
}
|
||||
injectAutoCompleteBindings(
|
||||
_mailboxDashBoardController.sessionCurrent,
|
||||
_mailboxDashBoardController.accountId.value);
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@@ -148,36 +155,55 @@ class AdvancedFilterController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<EmailAddress>> getAutoCompleteSuggestion(
|
||||
{required String word}) async {
|
||||
@override
|
||||
void injectAutoCompleteBindings(Session? session, AccountId? accountId) {
|
||||
try {
|
||||
super.injectAutoCompleteBindings(session, accountId);
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
} catch (e) {
|
||||
logError('AdvancedFilterController::injectAutoCompleteBindings(): $e');
|
||||
}
|
||||
}
|
||||
|
||||
if (!Get.isRegistered<GetAutoCompleteWithDeviceContactInteractor>() ||
|
||||
!Get.isRegistered<GetAutoCompleteInteractor>()) {
|
||||
_mailboxDashBoardController.injectAutoCompleteBindings();
|
||||
Future<List<EmailAddress>> getAutoCompleteSuggestion(String word) async {
|
||||
log('AdvancedFilterController::getAutoCompleteSuggestion(): $word | $_contactSuggestionSource');
|
||||
final accountId = _mailboxDashBoardController.accountId.value;
|
||||
|
||||
try {
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
} catch (e) {
|
||||
logError('AdvancedFilterController::getAutoCompleteSuggestion(): Exception $e');
|
||||
}
|
||||
|
||||
_getAutoCompleteWithDeviceContactInteractor = Get.find<GetAutoCompleteWithDeviceContactInteractor>();
|
||||
_getAutoCompleteInteractor = Get.find<GetAutoCompleteInteractor>();
|
||||
|
||||
if (_contactSuggestionSource == ContactSuggestionSource.all) {
|
||||
return await _getAutoCompleteWithDeviceContactInteractor
|
||||
.execute(AutoCompletePattern(
|
||||
word: word,
|
||||
accountId: _mailboxDashBoardController.accountId.value))
|
||||
if (_getAutoCompleteWithDeviceContactInteractor == null || _getAutoCompleteInteractor == null) {
|
||||
return <EmailAddress>[];
|
||||
}
|
||||
|
||||
final listEmailAddress = await _getAutoCompleteWithDeviceContactInteractor!
|
||||
.execute(AutoCompletePattern(word: word, accountId: accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
return listEmailAddress;
|
||||
} else {
|
||||
if (_getAutoCompleteInteractor == null) {
|
||||
return <EmailAddress>[];
|
||||
}
|
||||
|
||||
final listEmailAddress = await _getAutoCompleteInteractor!
|
||||
.execute(AutoCompletePattern(word: word, accountId: accountId))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
return listEmailAddress;
|
||||
}
|
||||
return await _getAutoCompleteInteractor
|
||||
.execute(AutoCompletePattern(
|
||||
word: word, accountId: _mailboxDashBoardController.accountId.value))
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
? success.listEmailAddress
|
||||
: <EmailAddress>[]));
|
||||
}
|
||||
|
||||
bool _checkAdvancedSearchHasApply() {
|
||||
@@ -219,4 +245,10 @@ class AdvancedFilterController extends GetxController {
|
||||
dateFilterInputController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onDone() {}
|
||||
|
||||
@override
|
||||
void onError(error) {}
|
||||
}
|
||||
|
||||
+2
-2
@@ -337,7 +337,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
if (arguments is Session) {
|
||||
sessionCurrent = arguments;
|
||||
accountId.value = sessionCurrent?.accounts.keys.first;
|
||||
injectAutoCompleteBindings();
|
||||
injectAutoCompleteBindings(sessionCurrent, accountId.value);
|
||||
injectVacationBindings(sessionCurrent, accountId.value);
|
||||
} else {
|
||||
if (kIsWeb) {
|
||||
@@ -885,7 +885,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
accountId.value = sessionCurrent?.accounts.keys.first;
|
||||
_getUserProfile();
|
||||
_handleComposerCache();
|
||||
injectAutoCompleteBindings();
|
||||
injectAutoCompleteBindings(sessionCurrent, accountId.value);
|
||||
injectVacationBindings(sessionCurrent, accountId.value);
|
||||
_getVacationResponse();
|
||||
}
|
||||
|
||||
+2
-6
@@ -246,9 +246,7 @@ class AdvancedSearchInputForm extends GetWidget<AdvancedFilterController>
|
||||
const Padding(padding: EdgeInsets.all(4)),
|
||||
_responsiveUtils.isMobile(context) || _responsiveUtils.landscapeTabletSupported(context)
|
||||
? TextFieldAutoCompleteEmailAddress(
|
||||
optionsBuilder: (word) async {
|
||||
return controller.getAutoCompleteSuggestion(word: word);
|
||||
},
|
||||
optionsBuilder: controller.getAutoCompleteSuggestion,
|
||||
advancedSearchFilterField: advancedSearchFilterField,
|
||||
initialTags: listTagInitial,
|
||||
currentFocusNode: currentFocusNode,
|
||||
@@ -282,9 +280,7 @@ class AdvancedSearchInputForm extends GetWidget<AdvancedFilterController>
|
||||
)
|
||||
: Expanded(
|
||||
child: TextFieldAutoCompleteEmailAddress(
|
||||
optionsBuilder: (word) async {
|
||||
return controller.getAutoCompleteSuggestion(word: word);
|
||||
},
|
||||
optionsBuilder: controller.getAutoCompleteSuggestion,
|
||||
advancedSearchFilterField: advancedSearchFilterField,
|
||||
initialTags: listTagInitial,
|
||||
currentFocusNode: currentFocusNode,
|
||||
|
||||
@@ -48,8 +48,8 @@ class ForwardController extends BaseController {
|
||||
|
||||
final selectionMode = Rx<SelectMode>(SelectMode.INACTIVE);
|
||||
final listRecipientForward = RxList<RecipientForward>();
|
||||
|
||||
final currentForward = Rxn<TMailForward>();
|
||||
final emailsForwardCreatorArguments = Rxn<MailsForwardCreatorArguments>();
|
||||
|
||||
final listForwards = <String>[].obs;
|
||||
|
||||
@@ -239,17 +239,13 @@ class ForwardController extends BaseController {
|
||||
|
||||
void goToAddEmailsForward() async {
|
||||
final accountId = accountDashBoardController.accountId.value;
|
||||
if (accountId != null) {
|
||||
final session = accountDashBoardController.sessionCurrent.value;
|
||||
if (accountId != null && session != null) {
|
||||
emailsForwardCreatorArguments.value = MailsForwardCreatorArguments(accountId, session);
|
||||
if (kIsWeb) {
|
||||
_openMailsForwardCreatorOverlay();
|
||||
} else {
|
||||
final listEmail = await push(
|
||||
AppRoutes.EMAILS_FORWARD_CREATOR,
|
||||
arguments: MailsForwardCreatorArguments(accountId, accountDashBoardController.sessionCurrent.value));
|
||||
|
||||
if (listEmail is List<EmailAddress>) {
|
||||
handleAddRecipients(listEmail);
|
||||
}
|
||||
push(AppRoutes.EMAILS_FORWARD_CREATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
accountId.value = session.accounts.keys.first;
|
||||
sessionCurrent.value = session;
|
||||
_getUserProfile();
|
||||
injectAutoCompleteBindings();
|
||||
injectAutoCompleteBindings(sessionCurrent.value, accountId.value);
|
||||
injectVacationBindings(sessionCurrent.value, accountId.value);
|
||||
_getVacationResponse();
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
accountId.value = arguments.session?.accounts.keys.first;
|
||||
sessionCurrent.value = arguments.session;
|
||||
_getUserProfile();
|
||||
injectAutoCompleteBindings();
|
||||
injectAutoCompleteBindings(sessionCurrent.value, accountId.value);
|
||||
injectVacationBindings(sessionCurrent.value, accountId.value);
|
||||
_getVacationResponse();
|
||||
if (arguments.menuSettingCurrent != null) {
|
||||
@@ -131,13 +131,13 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
_getAllVacationInteractor = Get.find<GetAllVacationInteractor>();
|
||||
_updateVacationInteractor = Get.find<UpdateVacationInteractor>();
|
||||
} catch (e) {
|
||||
logError('MailboxDashBoardController::injectVacationBindings(): $e');
|
||||
logError('ManageAccountDashBoardController::injectVacationBindings(): $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _getAppVersion() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
log('MailboxDashBoardController::_getAppVersion(): ${info.version}');
|
||||
log('ManageAccountDashBoardController::_getAppVersion(): ${info.version}');
|
||||
appInformation.value = info;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user