TF-3408 Remove limit result in autocomplete
This commit is contained in:
+10
-5
@@ -52,16 +52,21 @@ class ForwardRecipientController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<EmailAddress>> getAutoCompleteSuggestion(String word) async {
|
||||
log('ForwardRecipientController::getAutoCompleteSuggestion(): $word');
|
||||
Future<List<EmailAddress>> getAutoCompleteSuggestion(String word, {int? limit}) async {
|
||||
log('ForwardRecipientController::getAutoCompleteSuggestion():word = $word | limit = $limit');
|
||||
_getAllAutoCompleteInteractor = getBinding<GetAllAutoCompleteInteractor>();
|
||||
_getAutoCompleteInteractor = getBinding<GetAutoCompleteInteractor>();
|
||||
_getDeviceContactSuggestionsInteractor = getBinding<GetDeviceContactSuggestionsInteractor>();
|
||||
|
||||
final autoCompletePattern = AutoCompletePattern(
|
||||
word: word,
|
||||
limit: limit,
|
||||
accountId: _accountId,
|
||||
);
|
||||
if (_contactSuggestionSource == ContactSuggestionSource.all) {
|
||||
if (_getAllAutoCompleteInteractor != null) {
|
||||
return await _getAllAutoCompleteInteractor!
|
||||
.execute(AutoCompletePattern(word: word, accountId: _accountId))
|
||||
.execute(autoCompletePattern)
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
@@ -70,7 +75,7 @@ class ForwardRecipientController {
|
||||
));
|
||||
} else if (_getDeviceContactSuggestionsInteractor != null) {
|
||||
return await _getDeviceContactSuggestionsInteractor!
|
||||
.execute(AutoCompletePattern(word: word, accountId: _accountId))
|
||||
.execute(autoCompletePattern)
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetDeviceContactSuggestionsSuccess
|
||||
@@ -85,7 +90,7 @@ class ForwardRecipientController {
|
||||
return <EmailAddress>[];
|
||||
} else {
|
||||
return await _getAutoCompleteInteractor!
|
||||
.execute(AutoCompletePattern(word: word, accountId: _accountId))
|
||||
.execute(autoCompletePattern)
|
||||
.then((value) => value.fold(
|
||||
(failure) => <EmailAddress>[],
|
||||
(success) => success is GetAutoCompleteSuccess
|
||||
|
||||
+13
-4
@@ -26,7 +26,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_config.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
||||
|
||||
typedef OnSuggestionContactCallbackAction = Future<List<EmailAddress>> Function(String query);
|
||||
typedef OnSuggestionContactCallbackAction = Future<List<EmailAddress>> Function(String query, {int? limit});
|
||||
typedef OnAddListContactCallbackAction = Function(List<EmailAddress> listEmailAddress);
|
||||
typedef OnExceptionAddListContactCallbackAction = Function(Exception exception);
|
||||
|
||||
@@ -140,7 +140,13 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
|
||||
}
|
||||
),
|
||||
onTagChanged: (_) {},
|
||||
findSuggestions: _findSuggestions,
|
||||
findSuggestions: (queryString) => _findSuggestions(
|
||||
queryString,
|
||||
limit: AppConfig.defaultLimitAutocomplete,
|
||||
),
|
||||
isLoadMoreOnlyOnce: true,
|
||||
isLoadMoreReplaceAllOld: false,
|
||||
loadMoreSuggestions: _findSuggestions,
|
||||
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
@@ -200,7 +206,7 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
|
||||
.contains(inputEmail);
|
||||
}
|
||||
|
||||
FutureOr<List<SuggestionEmailAddress>> _findSuggestions(String query) async {
|
||||
FutureOr<List<SuggestionEmailAddress>> _findSuggestions(String query, {int? limit}) async {
|
||||
final processedQuery = query.trim();
|
||||
|
||||
if (processedQuery.isEmpty) {
|
||||
@@ -212,7 +218,10 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
|
||||
&& processedQuery.length >= widget.minInputLengthAutocomplete
|
||||
&& widget.onSuggestionCallback != null
|
||||
) {
|
||||
final addedEmailAddresses = await widget.onSuggestionCallback!(processedQuery);
|
||||
final addedEmailAddresses = await widget.onSuggestionCallback!(
|
||||
processedQuery,
|
||||
limit: limit,
|
||||
);
|
||||
final listSuggestionEmailAddress = addedEmailAddresses
|
||||
.map((emailAddress) => _toSuggestionEmailAddress(emailAddress, listEmailAddress))
|
||||
.toList();
|
||||
|
||||
Reference in New Issue
Block a user