mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Bug Fix - Contact search: Unexpected empty search result.
To reproduce: 1- search with "tst" pattern 2- erase the 2 last characters of the pattern to set "test" -> empty result NOK
This commit is contained in:
parent
9eef397eb3
commit
05d39d3893
1 changed files with 18 additions and 9 deletions
|
@ -148,14 +148,13 @@
|
|||
{
|
||||
// Update search results.
|
||||
searchText = [searchText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
NSMutableArray<MXKContact*> *unfilteredLocalContacts;
|
||||
NSMutableArray<MXKContact*> *unfilteredMatrixContacts;
|
||||
|
||||
searchProcessingCount++;
|
||||
|
||||
if (!searchText.length)
|
||||
{
|
||||
searchProcessingLocalContacts = nil;
|
||||
searchProcessingMatrixContacts = nil;
|
||||
|
||||
// Disclose by default the sections if a search was in progress.
|
||||
if (searchProcessingText.length)
|
||||
{
|
||||
|
@ -164,11 +163,9 @@
|
|||
}
|
||||
else if (forceRefresh || !searchProcessingText.length || [searchText hasPrefix:searchProcessingText] == NO)
|
||||
{
|
||||
// Retrieve all the local contacts
|
||||
searchProcessingLocalContacts = [self unfilteredLocalContactsArray];
|
||||
|
||||
// Retrieve all known matrix users
|
||||
searchProcessingMatrixContacts = [self unfilteredMatrixContactsArray];
|
||||
// Prepare on the main thread the arrays used to initialize the search on the processing queue.
|
||||
unfilteredLocalContacts = [self unfilteredLocalContactsArray];
|
||||
unfilteredMatrixContacts = [self unfilteredMatrixContactsArray];
|
||||
|
||||
// Disclose the sections
|
||||
shrinkedSectionsBitMask = 0;
|
||||
|
@ -176,6 +173,18 @@
|
|||
|
||||
dispatch_async(searchProcessingQueue, ^{
|
||||
|
||||
// Reset the current arrays if it is required
|
||||
if (!searchText.length)
|
||||
{
|
||||
searchProcessingLocalContacts = nil;
|
||||
searchProcessingMatrixContacts = nil;
|
||||
}
|
||||
else if (unfilteredLocalContacts)
|
||||
{
|
||||
searchProcessingLocalContacts = unfilteredLocalContacts;
|
||||
searchProcessingMatrixContacts = unfilteredMatrixContacts;
|
||||
}
|
||||
|
||||
for (NSUInteger index = 0; index < searchProcessingLocalContacts.count;)
|
||||
{
|
||||
MXKContact* contact = searchProcessingLocalContacts[index];
|
||||
|
|
Loading…
Reference in a new issue