diff --git a/lib/features/composer/presentation/composer_view.dart b/lib/features/composer/presentation/composer_view.dart index 47c42d6123..a7b9974bb4 100644 --- a/lib/features/composer/presentation/composer_view.dart +++ b/lib/features/composer/presentation/composer_view.dart @@ -124,6 +124,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listToEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, fromState: controller.fromRecipientState.value, ccState: controller.ccRecipientState.value, bccState: controller.bccRecipientState.value, @@ -150,6 +153,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listCcEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.ccAddressExpandMode.value, controller: controller.ccEmailAddressController, focusNode: controller.ccAddressFocusNode, @@ -176,6 +182,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listBccEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.bccAddressExpandMode.value, controller: controller.bccEmailAddressController, focusNode: controller.bccAddressFocusNode, @@ -280,6 +289,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listToEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, fromState: controller.fromRecipientState.value, ccState: controller.ccRecipientState.value, bccState: controller.bccRecipientState.value, @@ -305,6 +317,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listCcEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.ccAddressExpandMode.value, controller: controller.ccEmailAddressController, focusNode: controller.ccAddressFocusNode, @@ -326,6 +341,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listBccEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.bccAddressExpandMode.value, controller: controller.bccEmailAddressController, focusNode: controller.bccAddressFocusNode, diff --git a/lib/features/composer/presentation/composer_view_web.dart b/lib/features/composer/presentation/composer_view_web.dart index 6621e9f5f3..907f9eb386 100644 --- a/lib/features/composer/presentation/composer_view_web.dart +++ b/lib/features/composer/presentation/composer_view_web.dart @@ -89,6 +89,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listToEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, fromState: controller.fromRecipientState.value, ccState: controller.ccRecipientState.value, bccState: controller.bccRecipientState.value, @@ -115,6 +118,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listCcEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.ccAddressExpandMode.value, controller: controller.ccEmailAddressController, focusNode: controller.ccAddressFocusNode, @@ -138,6 +144,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listBccEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.bccAddressExpandMode.value, controller: controller.bccEmailAddressController, focusNode: controller.bccAddressFocusNode, @@ -328,6 +337,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listToEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, fromState: controller.fromRecipientState.value, ccState: controller.ccRecipientState.value, bccState: controller.bccRecipientState.value, @@ -354,6 +366,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listCcEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.ccAddressExpandMode.value, controller: controller.ccEmailAddressController, focusNode: controller.ccAddressFocusNode, @@ -377,6 +392,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listBccEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.bccAddressExpandMode.value, controller: controller.bccEmailAddressController, focusNode: controller.bccAddressFocusNode, @@ -600,6 +618,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listToEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, fromState: controller.fromRecipientState.value, ccState: controller.ccRecipientState.value, bccState: controller.bccRecipientState.value, @@ -626,6 +647,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listCcEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.ccAddressExpandMode.value, controller: controller.ccEmailAddressController, focusNode: controller.ccAddressFocusNode, @@ -649,6 +673,9 @@ class ComposerView extends GetWidget { listEmailAddress: controller.listBccEmailAddress, imagePaths: controller.imagePaths, maxWidth: constraints.maxWidth, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, expandMode: controller.bccAddressExpandMode.value, controller: controller.bccEmailAddressController, focusNode: controller.bccAddressFocusNode, diff --git a/lib/features/composer/presentation/widgets/recipient_composer_widget.dart b/lib/features/composer/presentation/widgets/recipient_composer_widget.dart index ff119e4889..c58c846632 100644 --- a/lib/features/composer/presentation/widgets/recipient_composer_widget.dart +++ b/lib/features/composer/presentation/widgets/recipient_composer_widget.dart @@ -64,6 +64,7 @@ class RecipientComposerWidget extends StatefulWidget { final EdgeInsetsGeometry? margin; final OnEnableAllRecipientsInputAction? onEnableAllRecipientsInputAction; final bool isTestingForWeb; + final int minInputLengthAutocomplete; const RecipientComposerWidget({ super.key, @@ -71,6 +72,7 @@ class RecipientComposerWidget extends StatefulWidget { required this.listEmailAddress, required this.imagePaths, required this.maxWidth, + this.minInputLengthAutocomplete = AppConfig.defaultMinInputLengthAutocomplete, @visibleForTesting this.isTestingForWeb = false, this.ccState = PrefixRecipientState.disabled, this.bccState = PrefixRecipientState.disabled, @@ -410,10 +412,13 @@ class _RecipientComposerWidgetState extends State { } final tmailSuggestion = List.empty(growable: true); - if (processedQuery.length >= AppConfig.limitCharToStartSearch && + if (processedQuery.length >= widget.minInputLengthAutocomplete && widget.onSuggestionEmailAddress != null) { final listEmailAddress = await widget.onSuggestionEmailAddress!(processedQuery); - final listSuggestionEmailAddress = listEmailAddress.map((emailAddress) => _toSuggestionEmailAddress(emailAddress, _currentListEmailAddress)); + final listSuggestionEmailAddress = listEmailAddress + .map((emailAddress) => _toSuggestionEmailAddress( + emailAddress, + _currentListEmailAddress)); tmailSuggestion.addAll(listSuggestionEmailAddress); } diff --git a/lib/features/contact/presentation/contact_controller.dart b/lib/features/contact/presentation/contact_controller.dart index cf4467667c..1fe3cef38e 100644 --- a/lib/features/contact/presentation/contact_controller.dart +++ b/lib/features/contact/presentation/contact_controller.dart @@ -55,6 +55,8 @@ class ContactController extends BaseController with AutoCompleteResultMixin { VoidCallback? onDismissContactView; StreamSubscription? _deBouncerTimeStreamSubscription; + late int _minInputLengthAutocomplete; + @override void onInit() { super.onInit(); @@ -79,6 +81,7 @@ class ContactController extends BaseController with AutoCompleteResultMixin { textInputSearchFocus.requestFocus(); } } + _minInputLengthAutocomplete = _fetchMinInputLengthAutocomplete(); if (PlatformInfo.isMobile) { Future.delayed( const Duration(milliseconds: 500), @@ -95,6 +98,7 @@ class ContactController extends BaseController with AutoCompleteResultMixin { textInputSearchController.dispose(); _deBouncerTimeStreamSubscription?.cancel(); _deBouncerTime.cancel(); + _accountId = null; super.onClose(); } @@ -115,7 +119,7 @@ class ContactController extends BaseController with AutoCompleteResultMixin { Future _handleDeBounceTimeSearchContact(String value) async { final queryStringTrimmed = value.trim(); - if (queryStringTrimmed.length < AppConfig.limitCharToStartSearch) { + if (queryStringTrimmed.length < _minInputLengthAutocomplete) { searchStatus.value = SearchStatus.INACTIVE; return; } @@ -235,4 +239,13 @@ class ContactController extends BaseController with AutoCompleteResultMixin { FocusManager.instance.primaryFocus?.unfocus(); searchStatus.value = SearchStatus.INACTIVE; } + + int _fetchMinInputLengthAutocomplete() { + if (contactArguments.value?.session == null || _accountId == null) { + return AppConfig.defaultMinInputLengthAutocomplete; + } + return getMinInputLengthAutocomplete( + session: contactArguments.value!.session, + accountId: _accountId!); + } } \ No newline at end of file diff --git a/lib/features/email_recovery/presentation/email_recovery_controller.dart b/lib/features/email_recovery/presentation/email_recovery_controller.dart index 1122da6041..d48991ddb2 100644 --- a/lib/features/email_recovery/presentation/email_recovery_controller.dart +++ b/lib/features/email_recovery/presentation/email_recovery_controller.dart @@ -27,6 +27,7 @@ import 'package:tmail_ui_user/features/email_recovery/presentation/model/email_r import 'package:tmail_ui_user/features/email_recovery/presentation/model/email_recovery_time_type.dart'; import 'package:tmail_ui_user/features/manage_account/presentation/extensions/datetime_extension.dart'; import 'package:tmail_ui_user/main/routes/route_navigation.dart'; +import 'package:tmail_ui_user/main/utils/app_config.dart'; class EmailRecoveryController extends BaseController with DateRangePickerMixin { GetAllAutoCompleteInteractor? _getAllAutoCompleteInteractor; @@ -87,6 +88,15 @@ class EmailRecoveryController extends BaseController with DateRangePickerMixin { super.onReady(); } + int get minInputLengthAutocomplete { + if (_session == null || _accountId == null) { + return AppConfig.defaultMinInputLengthAutocomplete; + } + return getMinInputLengthAutocomplete( + session: _session!, + accountId: _accountId!); + } + void _checkContactPermission() async { final permissionStatus = await Permission.contacts.status; if (permissionStatus.isGranted) { diff --git a/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_desktop_builder.dart b/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_desktop_builder.dart index bd6059faee..bf12da47f2 100644 --- a/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_desktop_builder.dart +++ b/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_desktop_builder.dart @@ -75,6 +75,7 @@ class EmailRecoveryFormDesktopBuilder extends GetWidget listEmailAddress: controller.listRecipients, responsiveUtils: controller.responsiveUtils, expandMode: controller.recipientsExpandMode.value, + minInputLengthAutocomplete: controller.minInputLengthAutocomplete, textEditingController: controller.recipientsFieldInputController, focusNode: controller.focusManager.recipientsFieldFocusNode, nextFocusNode: controller.listSenders.length != 1 @@ -90,6 +91,7 @@ class EmailRecoveryFormDesktopBuilder extends GetWidget listEmailAddress: controller.listSenders, responsiveUtils: controller.responsiveUtils, expandMode: controller.senderExpandMode.value, + minInputLengthAutocomplete: controller.minInputLengthAutocomplete, textEditingController: controller.senderFieldInputController, focusNode: controller.focusManager.senderFieldFocusNode, nextFocusNode: controller.focusManager.attachmentCheckboxFocusNode, diff --git a/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_mobile_builder.dart b/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_mobile_builder.dart index 732ab48d8f..8abd5307ea 100644 --- a/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_mobile_builder.dart +++ b/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_mobile_builder.dart @@ -73,6 +73,7 @@ class EmailRecoveryFormMobileBuilder extends GetWidget focusNode: controller.focusManager.recipientsFieldFocusNode, nextFocusNode: controller.focusManager.senderFieldFocusNode, expandMode: controller.recipientsExpandMode.value, + minInputLengthAutocomplete: controller.minInputLengthAutocomplete, textEditingController: controller.recipientsFieldInputController, onShowFullListEmailAddressAction: controller.showFullEmailAddress, onUpdateListEmailAddressAction: controller.updateListEmailAddress, @@ -86,6 +87,7 @@ class EmailRecoveryFormMobileBuilder extends GetWidget focusNode: controller.focusManager.senderFieldFocusNode, nextFocusNode: controller.focusManager.attachmentCheckboxFocusNode, expandMode: controller.senderExpandMode.value, + minInputLengthAutocomplete: controller.minInputLengthAutocomplete, textEditingController: controller.senderFieldInputController, onShowFullListEmailAddressAction: controller.showFullEmailAddress, onUpdateListEmailAddressAction: controller.updateListEmailAddress, diff --git a/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_tablet_builder.dart b/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_tablet_builder.dart index 257a32cdc8..0ad9f9170b 100644 --- a/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_tablet_builder.dart +++ b/lib/features/email_recovery/presentation/widgets/email_recovery_form/email_recovery_form_tablet_builder.dart @@ -75,6 +75,7 @@ class EmailRecoveryFormTabletBuilder extends GetWidget listEmailAddress: controller.listRecipients, responsiveUtils: controller.responsiveUtils, expandMode: controller.recipientsExpandMode.value, + minInputLengthAutocomplete: controller.minInputLengthAutocomplete, textEditingController: controller.recipientsFieldInputController, focusNode: controller.focusManager.recipientsFieldFocusNode, nextFocusNode: controller.focusManager.senderFieldFocusNode, @@ -88,6 +89,7 @@ class EmailRecoveryFormTabletBuilder extends GetWidget listEmailAddress: controller.listSenders, responsiveUtils: controller.responsiveUtils, expandMode: controller.senderExpandMode.value, + minInputLengthAutocomplete: controller.minInputLengthAutocomplete, textEditingController: controller.senderFieldInputController, focusNode: controller.focusManager.senderFieldFocusNode, nextFocusNode: controller.focusManager.attachmentCheckboxFocusNode, diff --git a/lib/features/email_recovery/presentation/widgets/text_input_field/text_input_field_suggestion_widget.dart b/lib/features/email_recovery/presentation/widgets/text_input_field/text_input_field_suggestion_widget.dart index 1766aee4a7..60e4fd33ab 100644 --- a/lib/features/email_recovery/presentation/widgets/text_input_field/text_input_field_suggestion_widget.dart +++ b/lib/features/email_recovery/presentation/widgets/text_input_field/text_input_field_suggestion_widget.dart @@ -40,6 +40,7 @@ class TextInputFieldSuggestionWidget extends StatefulWidget { final OnDeleteTagAction? onDeleteTagAction; final TextEditingController? textEditingController; final VoidCallback? onCreateAction; + final int minInputLengthAutocomplete; const TextInputFieldSuggestionWidget({ super.key, @@ -47,6 +48,7 @@ class TextInputFieldSuggestionWidget extends StatefulWidget { required this.listEmailAddress, required this.responsiveUtils, this.expandMode = ExpandMode.EXPAND, + this.minInputLengthAutocomplete = AppConfig.defaultMinInputLengthAutocomplete, this.focusNode, this.keyTagEditor, this.nextFocusNode, @@ -325,7 +327,7 @@ class _TextInputFieldSuggestionWidgetState extends State.empty(growable: true); if ( - processedQuery.length >= AppConfig.limitCharToStartSearch + processedQuery.length >= widget.minInputLengthAutocomplete && widget.onSuggestionEmailAddress != null ) { final listEmailAddress = await widget.onSuggestionEmailAddress!(processedQuery); diff --git a/lib/features/mailbox_dashboard/presentation/controller/advanced_filter_controller.dart b/lib/features/mailbox_dashboard/presentation/controller/advanced_filter_controller.dart index e91de1fd39..583fed6a3f 100644 --- a/lib/features/mailbox_dashboard/presentation/controller/advanced_filter_controller.dart +++ b/lib/features/mailbox_dashboard/presentation/controller/advanced_filter_controller.dart @@ -98,7 +98,6 @@ class AdvancedFilterController extends BaseController { _memorySearchFilter = searchFilter; } - @visibleForTesting MailboxDashBoardController get mailboxDashBoardController => _mailboxDashBoardController; void _updateMemorySearchFilter({ diff --git a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart index bd5ca0ee12..9a532c1230 100644 --- a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart +++ b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart @@ -160,6 +160,7 @@ import 'package:tmail_ui_user/main/routes/navigation_router.dart'; import 'package:tmail_ui_user/main/routes/route_navigation.dart'; import 'package:tmail_ui_user/main/routes/route_utils.dart'; import 'package:tmail_ui_user/main/universal_import/html_stub.dart' as html; +import 'package:tmail_ui_user/main/utils/app_config.dart'; import 'package:tmail_ui_user/main/utils/email_receive_manager.dart'; import 'package:tmail_ui_user/main/utils/ios_notification_manager.dart'; import 'package:uuid/uuid.dart'; @@ -2556,6 +2557,10 @@ class MailboxDashBoardController extends ReloadableController with UserSettingPo return []; } + if (query.length < minInputLengthAutocomplete) { + return []; + } + final listEmailAddress = await _getAutoCompleteInteractor! .execute(AutoCompletePattern(word: query, accountId: accountId.value!, limit: 2)) .then((value) => value.fold( @@ -2908,6 +2913,15 @@ class MailboxDashBoardController extends ReloadableController with UserSettingPo dispatchAction(ClearSearchFilterAppliedAction()); } + int get minInputLengthAutocomplete { + if (sessionCurrent == null || accountId.value == null) { + return AppConfig.defaultMinInputLengthAutocomplete; + } + return getMinInputLengthAutocomplete( + session: sessionCurrent!, + accountId: accountId.value!); + } + @override void onClose() { if (PlatformInfo.isWeb) { diff --git a/lib/features/mailbox_dashboard/presentation/widgets/advanced_search/advanced_search_input_form.dart b/lib/features/mailbox_dashboard/presentation/widgets/advanced_search/advanced_search_input_form.dart index 9a043c921e..572b1407f3 100644 --- a/lib/features/mailbox_dashboard/presentation/widgets/advanced_search/advanced_search_input_form.dart +++ b/lib/features/mailbox_dashboard/presentation/widgets/advanced_search/advanced_search_input_form.dart @@ -31,6 +31,9 @@ class AdvancedSearchInputForm extends GetWidget field: AdvancedSearchFilterField.from, listEmailAddress: controller.listFromEmailAddress, expandMode: controller.fromAddressExpandMode.value, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, controller: controller.fromEmailAddressController, focusNode: controller.focusManager.fromFieldFocusNode, nextFocusNode: controller.focusManager.toFieldFocusNode, @@ -45,6 +48,9 @@ class AdvancedSearchInputForm extends GetWidget field: AdvancedSearchFilterField.to, listEmailAddress: controller.listToEmailAddress, expandMode: controller.toAddressExpandMode.value, + minInputLengthAutocomplete: controller + .mailboxDashBoardController + .minInputLengthAutocomplete, controller: controller.toEmailAddressController, focusNode: controller.focusManager.toFieldFocusNode, nextFocusNode: controller.focusManager.subjectFieldFocusNode, diff --git a/lib/features/mailbox_dashboard/presentation/widgets/advanced_search/text_field_autocomplete_email_address_web.dart b/lib/features/mailbox_dashboard/presentation/widgets/advanced_search/text_field_autocomplete_email_address_web.dart index a8f7629834..1eeb8a7170 100644 --- a/lib/features/mailbox_dashboard/presentation/widgets/advanced_search/text_field_autocomplete_email_address_web.dart +++ b/lib/features/mailbox_dashboard/presentation/widgets/advanced_search/text_field_autocomplete_email_address_web.dart @@ -45,12 +45,14 @@ class TextFieldAutocompleteEmailAddressWeb extends StatefulWidget { final OnRemoveDraggableEmailAddressAction? onRemoveDraggableEmailAddressAction; final TextEditingController? controller; final VoidCallback? onSearchAction; + final int minInputLengthAutocomplete; const TextFieldAutocompleteEmailAddressWeb({ Key? key, required this.field, required this.listEmailAddress, this.expandMode = ExpandMode.EXPAND, + this.minInputLengthAutocomplete = AppConfig.defaultMinInputLengthAutocomplete, this.focusNode, this.keyTagEditor, this.nextFocusNode, @@ -242,7 +244,7 @@ class _TextFieldAutocompleteEmailAddressWebState extends State.empty(growable: true); - if (processedQuery.length >= AppConfig.limitCharToStartSearch && + if (processedQuery.length >= widget.minInputLengthAutocomplete && widget.onSuggestionEmailAddress != null) { final listEmailAddress = await widget.onSuggestionEmailAddress!(processedQuery); final listSuggestionEmailAddress = listEmailAddress.map((emailAddress) => _toSuggestionEmailAddress(emailAddress, _currentListEmailAddress)); diff --git a/lib/features/mailbox_dashboard/presentation/widgets/search_input_form_widget.dart b/lib/features/mailbox_dashboard/presentation/widgets/search_input_form_widget.dart index 5f1c1e5337..6d9869f32a 100644 --- a/lib/features/mailbox_dashboard/presentation/widgets/search_input_form_widget.dart +++ b/lib/features/mailbox_dashboard/presentation/widgets/search_input_form_widget.dart @@ -30,7 +30,6 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/qu import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/search_filters/search_filter_button.dart'; import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; -import 'package:tmail_ui_user/main/utils/app_config.dart'; class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin { final _searchController = Get.find(); @@ -67,7 +66,7 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin { child: QuickSearchInputForm( maxHeight: 52, suggestionsBoxVerticalOffset: 0.0, - minInputLengthAutocomplete: AppConfig.limitCharToStartSearch, + minInputLengthAutocomplete: _dashBoardController.minInputLengthAutocomplete, textFieldConfiguration: _createConfiguration(context), suggestionsBoxDecoration: const QuickSearchSuggestionsBoxDecoration( color: Colors.white, diff --git a/lib/features/manage_account/presentation/forward/forward_view.dart b/lib/features/manage_account/presentation/forward/forward_view.dart index 2a3882002a..7719322b9a 100644 --- a/lib/features/manage_account/presentation/forward/forward_view.dart +++ b/lib/features/manage_account/presentation/forward/forward_view.dart @@ -127,6 +127,7 @@ class ForwardView extends GetWidget with AppLoaderMixin { return AutocompleteContactTextFieldWithTags( listEmailAddress: controller.recipientController.listRecipients, internalDomain: controller.accountDashBoardController.sessionCurrent?.internalDomain ?? '', + minInputLengthAutocomplete: controller.accountDashBoardController.minInputLengthAutocomplete, controller: controller.recipientController.inputRecipientController, onSuggestionCallback: controller.recipientController.getAutoCompleteSuggestion, hasAddContactButton: true, diff --git a/lib/features/manage_account/presentation/forward/widgets/autocomplete_contact_text_field_with_tags.dart b/lib/features/manage_account/presentation/forward/widgets/autocomplete_contact_text_field_with_tags.dart index 59f5407de1..0b25f2c54d 100644 --- a/lib/features/manage_account/presentation/forward/widgets/autocomplete_contact_text_field_with_tags.dart +++ b/lib/features/manage_account/presentation/forward/widgets/autocomplete_contact_text_field_with_tags.dart @@ -39,6 +39,7 @@ class AutocompleteContactTextFieldWithTags extends StatefulWidget { final OnAddListContactCallbackAction? onAddContactCallback; final OnExceptionAddListContactCallbackAction? onExceptionCallback; final String internalDomain; + final int minInputLengthAutocomplete; const AutocompleteContactTextFieldWithTags({ Key? key, @@ -46,6 +47,7 @@ class AutocompleteContactTextFieldWithTags extends StatefulWidget { required this.internalDomain, this.controller, this.hasAddContactButton = false, + this.minInputLengthAutocomplete = AppConfig.defaultMinInputLengthAutocomplete, this.onSuggestionCallback, this.onAddContactCallback, this.onExceptionCallback, @@ -206,7 +208,10 @@ class _AutocompleteContactTextFieldWithTagsState extends State.empty(growable: true); - if (processedQuery.isNotEmpty && widget.onSuggestionCallback != null) { + if (processedQuery.isNotEmpty + && processedQuery.length >= widget.minInputLengthAutocomplete + && widget.onSuggestionCallback != null + ) { final addedEmailAddresses = await widget.onSuggestionCallback!(processedQuery); final listSuggestionEmailAddress = addedEmailAddresses .map((emailAddress) => _toSuggestionEmailAddress(emailAddress, listEmailAddress)) diff --git a/lib/features/manage_account/presentation/manage_account_dashboard_controller.dart b/lib/features/manage_account/presentation/manage_account_dashboard_controller.dart index 16f63df27b..ae57d913aa 100644 --- a/lib/features/manage_account/presentation/manage_account_dashboard_controller.dart +++ b/lib/features/manage_account/presentation/manage_account_dashboard_controller.dart @@ -39,6 +39,7 @@ import 'package:tmail_ui_user/main/routes/app_routes.dart'; import 'package:tmail_ui_user/main/routes/navigation_router.dart'; import 'package:tmail_ui_user/main/routes/route_navigation.dart'; import 'package:tmail_ui_user/main/routes/route_utils.dart'; +import 'package:tmail_ui_user/main/utils/app_config.dart'; class ManageAccountDashBoardController extends ReloadableController with UserSettingPopupMenuMixin { @@ -372,6 +373,15 @@ class ManageAccountDashBoardController extends ReloadableController with UserSet ); } + int get minInputLengthAutocomplete { + if (sessionCurrent == null || accountId.value == null) { + return AppConfig.defaultMinInputLengthAutocomplete; + } + return getMinInputLengthAutocomplete( + session: sessionCurrent!, + accountId: accountId.value!); + } + @override void onClose() { BackButtonInterceptor.removeByName(AppRoutes.settings); diff --git a/test/features/composer/presentation/composer_controller_test.dart b/test/features/composer/presentation/composer_controller_test.dart index 17a66d7fea..fa4e11ed4d 100644 --- a/test/features/composer/presentation/composer_controller_test.dart +++ b/test/features/composer/presentation/composer_controller_test.dart @@ -64,6 +64,8 @@ import 'package:tmail_ui_user/features/upload/domain/usecases/local_image_picker import 'package:tmail_ui_user/features/upload/presentation/controller/upload_controller.dart'; import 'package:tmail_ui_user/features/upload/presentation/model/upload_file_state.dart'; import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart'; +import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart'; +import 'package:tmail_ui_user/main/utils/app_config.dart'; import 'package:tmail_ui_user/main/utils/toast_manager.dart'; import 'package:uuid/uuid.dart'; @@ -120,6 +122,9 @@ class MockMailboxDashBoardController extends Mock implements MailboxDashBoardCon @override String get baseDownloadUrl => ''; + + @override + int get minInputLengthAutocomplete => AppConfig.defaultMinInputLengthAutocomplete; } @GenerateNiceMocks([ @@ -156,6 +161,7 @@ class MockMailboxDashBoardController extends Mock implements MailboxDashBoardCon MockSpec(fallbackGenerators: fallbackGenerators), MockSpec(), MockSpec(fallbackGenerators: fallbackGenerators), + MockSpec(), // Additional misc dependencies mock specs MockSpec(), @@ -198,6 +204,7 @@ void main() { final mockBeforeReconnectManager = MockBeforeReconnectManager(); final mockRichTextMobileTabletController = MockRichTextMobileTabletController(); final mockRichTextWebController = MockRichTextWebController(); + final mockCacheExceptionThrower = MockCacheExceptionThrower(); // Declaration misc dependencies late MockHtmlEditorApi mockHtmlEditorApi; @@ -240,6 +247,7 @@ void main() { Get.put(mockNetworkConnectionController); Get.put(mockBeforeReconnectManager); Get.put(mockRichTextMobileTabletController); + Get.put(mockCacheExceptionThrower); // Mock composer controller mockLocalFilePickerInteractor = MockLocalFilePickerInteractor(); @@ -254,7 +262,7 @@ void main() { mockGetAlwaysReadReceiptSettingInteractor = MockGetAlwaysReadReceiptSettingInteractor(); mockCreateNewAndSendEmailInteractor = MockCreateNewAndSendEmailInteractor(); mockCreateNewAndSaveEmailToDraftsInteractor = MockCreateNewAndSaveEmailToDraftsInteractor(); - + composerController = ComposerController( mockLocalFilePickerInteractor, mockLocalImagePickerInteractor,