mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-19 08:03:50 +02:00
Merge branch 'develop' into doug/4484_contacts_access
This commit is contained in:
@@ -206,21 +206,25 @@
|
||||
[hsUserDirectoryOperation cancel];
|
||||
hsUserDirectoryOperation = nil;
|
||||
}
|
||||
|
||||
MXWeakify(self);
|
||||
|
||||
hsUserDirectoryOperation = [self.mxSession.matrixRestClient searchUsers:searchText limit:50 success:^(MXUserSearchResponse *userSearchResponse) {
|
||||
|
||||
filteredMatrixContacts = [NSMutableArray arrayWithCapacity:userSearchResponse.results.count];
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
self->filteredMatrixContacts = [NSMutableArray arrayWithCapacity:userSearchResponse.results.count];
|
||||
|
||||
// Keep the response order as the hs ordered users by relevance
|
||||
for (MXUser *mxUser in userSearchResponse.results)
|
||||
{
|
||||
MXKContact *contact = [[MXKContact alloc] initMatrixContactWithDisplayName:mxUser.displayname andMatrixID:mxUser.userId];
|
||||
[filteredMatrixContacts addObject:contact];
|
||||
[self->filteredMatrixContacts addObject:contact];
|
||||
}
|
||||
|
||||
hsUserDirectoryOperation = nil;
|
||||
self->hsUserDirectoryOperation = nil;
|
||||
|
||||
_userDirectoryState = userSearchResponse.limited ? ContactsDataSourceUserDirectoryStateLoadedButLimited : ContactsDataSourceUserDirectoryStateLoaded;
|
||||
self->_userDirectoryState = userSearchResponse.limited ? ContactsDataSourceUserDirectoryStateLoadedButLimited : ContactsDataSourceUserDirectoryStateLoaded;
|
||||
|
||||
// And inform the delegate about the update
|
||||
[self.delegate dataSource:self didCellChange:nil];
|
||||
@@ -240,28 +244,32 @@
|
||||
// Disclose the sections
|
||||
shrinkedSectionsBitMask = 0;
|
||||
}
|
||||
|
||||
MXWeakify(self);
|
||||
|
||||
dispatch_async(searchProcessingQueue, ^{
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
// Reset the current arrays if it is required
|
||||
if (!searchText.length)
|
||||
{
|
||||
searchProcessingLocalContacts = nil;
|
||||
searchProcessingMatrixContacts = nil;
|
||||
self->searchProcessingLocalContacts = nil;
|
||||
self->searchProcessingMatrixContacts = nil;
|
||||
}
|
||||
else if (unfilteredLocalContacts)
|
||||
{
|
||||
searchProcessingLocalContacts = unfilteredLocalContacts;
|
||||
searchProcessingMatrixContacts = unfilteredMatrixContacts;
|
||||
self->searchProcessingLocalContacts = unfilteredLocalContacts;
|
||||
self->searchProcessingMatrixContacts = unfilteredMatrixContacts;
|
||||
}
|
||||
|
||||
for (NSUInteger index = 0; index < searchProcessingLocalContacts.count;)
|
||||
for (NSUInteger index = 0; index < self->searchProcessingLocalContacts.count;)
|
||||
{
|
||||
MXKContact* contact = searchProcessingLocalContacts[index];
|
||||
MXKContact* contact = self->searchProcessingLocalContacts[index];
|
||||
|
||||
if (![contact hasPrefix:searchText])
|
||||
{
|
||||
[searchProcessingLocalContacts removeObjectAtIndex:index];
|
||||
[self->searchProcessingLocalContacts removeObjectAtIndex:index];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -270,13 +278,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
for (NSUInteger index = 0; index < searchProcessingMatrixContacts.count;)
|
||||
for (NSUInteger index = 0; index < self->searchProcessingMatrixContacts.count;)
|
||||
{
|
||||
MXKContact* contact = searchProcessingMatrixContacts[index];
|
||||
MXKContact* contact = self->searchProcessingMatrixContacts[index];
|
||||
|
||||
if (![contact hasPrefix:searchText])
|
||||
{
|
||||
[searchProcessingMatrixContacts removeObjectAtIndex:index];
|
||||
[self->searchProcessingMatrixContacts removeObjectAtIndex:index];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -286,42 +294,41 @@
|
||||
}
|
||||
|
||||
// Sort the refreshed list of the invitable contacts
|
||||
[[MXKContactManager sharedManager] sortAlphabeticallyContacts:searchProcessingLocalContacts];
|
||||
[[MXKContactManager sharedManager] sortContactsByLastActiveInformation:searchProcessingMatrixContacts];
|
||||
[[MXKContactManager sharedManager] sortAlphabeticallyContacts:self->searchProcessingLocalContacts];
|
||||
[[MXKContactManager sharedManager] sortContactsByLastActiveInformation:self->searchProcessingMatrixContacts];
|
||||
|
||||
searchProcessingText = searchText;
|
||||
self->searchProcessingText = searchText;
|
||||
|
||||
MXWeakify(self);
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
|
||||
// Sanity check: check whether self has been destroyed.
|
||||
if (!searchProcessingQueue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
// Render the search result only if there is no other search in progress.
|
||||
searchProcessingCount --;
|
||||
self->searchProcessingCount --;
|
||||
|
||||
if (!searchProcessingCount)
|
||||
if (!self->searchProcessingCount)
|
||||
{
|
||||
if (!forceSearchResultRefresh)
|
||||
if (!self->forceSearchResultRefresh)
|
||||
{
|
||||
// Update the filtered contacts.
|
||||
currentSearchText = searchProcessingText;
|
||||
filteredLocalContacts = searchProcessingLocalContacts;
|
||||
self->currentSearchText = self->searchProcessingText;
|
||||
self->filteredLocalContacts = self->searchProcessingLocalContacts;
|
||||
|
||||
if (!hsUserDirectory)
|
||||
{
|
||||
filteredMatrixContacts = searchProcessingMatrixContacts;
|
||||
_userDirectoryState = ContactsDataSourceUserDirectoryStateOfflineLoaded;
|
||||
self->filteredMatrixContacts = self->searchProcessingMatrixContacts;
|
||||
self->_userDirectoryState = ContactsDataSourceUserDirectoryStateOfflineLoaded;
|
||||
}
|
||||
|
||||
if (!self.forceMatrixIdInDisplayName)
|
||||
{
|
||||
[isMultiUseNameByDisplayName removeAllObjects];
|
||||
for (MXKContact* contact in filteredMatrixContacts)
|
||||
[self->isMultiUseNameByDisplayName removeAllObjects];
|
||||
for (MXKContact* contact in self->filteredMatrixContacts)
|
||||
{
|
||||
isMultiUseNameByDisplayName[contact.displayName] = (isMultiUseNameByDisplayName[contact.displayName] ? @(YES) : @(NO));
|
||||
self->isMultiUseNameByDisplayName[contact.displayName] = (self->isMultiUseNameByDisplayName[contact.displayName] ? @(YES) : @(NO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,8 +338,8 @@
|
||||
else
|
||||
{
|
||||
// Launch a new search
|
||||
forceSearchResultRefresh = NO;
|
||||
[self searchWithPattern:searchProcessingText forceReset:YES];
|
||||
self->forceSearchResultRefresh = NO;
|
||||
[self searchWithPattern:self->searchProcessingText forceReset:YES];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user