mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-24 00:16:39 +02:00
Public rooms search: Do a AND search on public rooms
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
|
||||
/**
|
||||
The filter being applied. Nil if there is no filter.
|
||||
A 'OR' search is made on the strings of the array.
|
||||
A 'AND' search is made with the strings of the array.
|
||||
Setting a new value may trigger a request to the home server. So, the data source state
|
||||
may change to MXKDataSourceStatePreparing.
|
||||
*/
|
||||
|
||||
@@ -124,15 +124,21 @@ double const kPublicRoomsDirectoryDataExpiration = 10;
|
||||
{
|
||||
if ([filteredRooms indexOfObjectIdenticalTo:publicRoom] == NSNotFound)
|
||||
{
|
||||
// Do a OR search
|
||||
// Do a AND search
|
||||
BOOL matchAll = YES;
|
||||
for (NSString *pattern in _searchPatternsList)
|
||||
{
|
||||
if ([publicRoom.displayname rangeOfString:pattern options:NSCaseInsensitiveSearch].location != NSNotFound)
|
||||
if (pattern.length && NO == [publicRoom.displayname localizedCaseInsensitiveContainsString:pattern])
|
||||
{
|
||||
[filteredRooms addObject:publicRoom];
|
||||
matchAll = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchAll)
|
||||
{
|
||||
[filteredRooms addObject:publicRoom];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -490,10 +490,13 @@
|
||||
{
|
||||
self.selectedViewController.view.hidden = NO;
|
||||
|
||||
// Do a AND search on words separated by a space
|
||||
NSArray *patterns = [searchBar.text componentsSeparatedByString:@" "];
|
||||
|
||||
// Forward the search request to the data source
|
||||
if (self.selectedViewController == recentsViewController)
|
||||
{
|
||||
[recentsDataSource searchWithPatterns:@[searchBar.text]];
|
||||
[recentsDataSource searchWithPatterns:patterns];
|
||||
recentsViewController.shouldScrollToTopOnRefresh = YES;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user