private List <TLUser> GetUsernames(string username) { var query = LocaleHelper.GetQuery(username); bool IsMatch(TLUser user) { if (user.Username == null) { return(false); } return(user.IsLike(query, StringComparison.OrdinalIgnoreCase)); } var results = new List <TLUser>(); if (ViewModel.Full is TLChatFull chatFull && chatFull.Participants is TLChatParticipants chatParticipants) { foreach (var participant in chatParticipants.Participants) { if (participant.User != null && IsMatch(participant.User)) { results.Add(participant.User); } } }
public void SearchSync(string query) { if (string.IsNullOrEmpty(query)) { Search.Clear(); return; } var queries = LocaleHelper.GetQuery(query); var contacts = CacheService.GetContacts().OfType <TLUser>().Where(x => x.IsLike(queries, StringComparison.OrdinalIgnoreCase)).ToList(); if (query.Equals(_searchQuery)) { if (Search.Count > 1) { Search.RemoveAt(1); } if (Search.Count > 0) { Search.RemoveAt(0); } //if (contacts.Count > 0) Search.Add(new KeyedList<string, TLObject>(null, contacts)); Search.Add(new KeyedList <string, TLObject>(null, contacts)); } }
private async Task <KeyedList <string, TLObject> > SearchLocalAsync(string query1) { var query = LocaleHelper.GetQuery(query1); var dialogs = await Task.Run(() => CacheService.GetDialogs()); var contacts = await Task.Run(() => CacheService.GetContacts()); if (dialogs != null && contacts != null) { var simple = new List <TLUser>(); var contactsResults = contacts.OfType <TLUser>().Where(x => SelectedItems.All(selectedUser => selectedUser.Id != x.Id) && x.IsLike(query, StringComparison.OrdinalIgnoreCase)); foreach (var result in contactsResults) { simple.Add(result); } if (simple.Count > 0) { return(new KeyedList <string, TLObject>(null, simple)); } } return(null); }
private List <TLUser> GetUsernames(string username) { var query = LocaleHelper.GetQuery(username); bool IsMatch(TLUser user) { return(user.IsLike(query, StringComparison.OrdinalIgnoreCase)); } var results = new List <TLUser>(); if (View.Dialog.Full is TLChatFull chatFull && chatFull.Participants is TLChatParticipants chatParticipants) { foreach (var participant in chatParticipants.Participants) { if (participant.User != null && IsMatch(participant.User)) { // Results should be upside down results.Insert(0, participant.User); } } }