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:
Giom Foret 2017-06-20 14:36:14 +02:00
parent 9eef397eb3
commit 05d39d3893

View file

@ -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];