mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-01 05:36:57 +02:00
Bug Fix: Room Participants - Search result: the user id should be displayed when 2 members has the same display name
https://github.com/vector-im/vector-ios/issues/293
This commit is contained in:
@@ -42,6 +42,10 @@
|
||||
// Contact instances by matrix user id, or room 3pid invite token.
|
||||
NSMutableDictionary *contactsById;
|
||||
|
||||
// When a search session is in progress, this dictionary tells for each display name
|
||||
// whether it appears several times.
|
||||
NSMutableDictionary <NSString*,NSNumber*> *isMultiUseNameByDisplayName;
|
||||
|
||||
MXKAlert *currentAlert;
|
||||
|
||||
// Mask view while processing a request
|
||||
@@ -135,6 +139,8 @@
|
||||
|
||||
contactsById = nil;
|
||||
|
||||
isMultiUseNameByDisplayName = nil;
|
||||
|
||||
actualParticipants = nil;
|
||||
invitedParticipants = nil;
|
||||
userContact = nil;
|
||||
@@ -418,6 +424,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reloadSearchResult
|
||||
{
|
||||
if (currentSearchText.length)
|
||||
{
|
||||
NSString *searchText = currentSearchText;
|
||||
currentSearchText = nil;
|
||||
|
||||
[self searchBar:_searchBarView textDidChange:searchText];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addRoomThirdPartyInviteToParticipants:(MXRoomThirdPartyInvite*)roomThirdPartyInvite
|
||||
{
|
||||
// If the homeserver has converted the 3pid invite into a room member, do no show it
|
||||
@@ -567,6 +584,9 @@
|
||||
{
|
||||
[contactsById setObject:userContact forKey:userContact.mxMember.userId];
|
||||
}
|
||||
|
||||
// Reload search result if any
|
||||
[self reloadSearchResult];
|
||||
}
|
||||
|
||||
- (void)addPendingActionMask
|
||||
@@ -718,6 +738,19 @@
|
||||
contact = invitableContacts[indexPath.row];
|
||||
|
||||
participantCell.selectionStyle = UITableViewCellSelectionStyleDefault;
|
||||
|
||||
// Disambiguate the display name when it appears several times.
|
||||
if (contact.displayName && [isMultiUseNameByDisplayName[contact.displayName] isEqualToNumber:@(YES)])
|
||||
{
|
||||
NSArray *identifiers = contact.matrixIdentifiers;
|
||||
if (identifiers.count)
|
||||
{
|
||||
NSString *participantId = identifiers.firstObject;
|
||||
NSString *displayName = [NSString stringWithFormat:@"%@ (%@)", contact.displayName, participantId];
|
||||
|
||||
contact = [[Contact alloc] initMatrixContactWithDisplayName:displayName andMatrixID:participantId];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -756,6 +789,36 @@
|
||||
if (index < participants.count)
|
||||
{
|
||||
contact = participants[index];
|
||||
|
||||
// Sanity check
|
||||
if (contact && contact.mxMember.userId)
|
||||
{
|
||||
// Disambiguate the display name when it appears several times.
|
||||
NSString *disambiguatedDisplayName;
|
||||
|
||||
if (self.isAddParticipantSearchBarEditing)
|
||||
{
|
||||
// Consider here the dictionary which lists all the display names of the search result.
|
||||
if ([isMultiUseNameByDisplayName[contact.displayName] isEqualToNumber:@(YES)])
|
||||
{
|
||||
disambiguatedDisplayName = [NSString stringWithFormat:@"%@ (%@)", contact.displayName, contact.mxMember.userId];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update the display name by considering the current room state.
|
||||
disambiguatedDisplayName = [self.mxRoom.state memberName:contact.mxMember.userId];
|
||||
if ([disambiguatedDisplayName isEqualToString:contact.displayName])
|
||||
{
|
||||
disambiguatedDisplayName = nil;
|
||||
}
|
||||
}
|
||||
|
||||
if (disambiguatedDisplayName)
|
||||
{
|
||||
contact = [[Contact alloc] initMatrixContactWithDisplayName:disambiguatedDisplayName andMatrixID:contact.mxMember.userId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
participantCell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
@@ -1360,8 +1423,7 @@
|
||||
{
|
||||
if ([contactsById objectForKey:userId] == nil)
|
||||
{
|
||||
Contact *splitContact = [[Contact alloc] initMatrixContactWithDisplayName:contact.displayName andMatrixID:userId];
|
||||
splitContact.mxMember = [self.mxRoom.state memberWithUserId:userId];
|
||||
MXKContact *splitContact = [[MXKContact alloc] initMatrixContactWithDisplayName:contact.displayName andMatrixID:userId];
|
||||
[contacts addObject:splitContact];
|
||||
}
|
||||
}
|
||||
@@ -1382,6 +1444,8 @@
|
||||
}
|
||||
currentSearchText = searchText;
|
||||
|
||||
isMultiUseNameByDisplayName = [NSMutableDictionary dictionary];
|
||||
|
||||
// Update invitable contacts list:
|
||||
invitableContacts = [NSMutableArray array];
|
||||
if (searchText.length)
|
||||
@@ -1395,6 +1459,8 @@
|
||||
if ([contact matchedWithPatterns:@[currentSearchText]])
|
||||
{
|
||||
[invitableContacts addObject:contact];
|
||||
|
||||
isMultiUseNameByDisplayName[contact.displayName] = (isMultiUseNameByDisplayName[contact.displayName] ? @(YES) : @(NO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1405,6 +1471,8 @@
|
||||
if ([contact matchedWithPatterns:@[currentSearchText]])
|
||||
{
|
||||
[filteredActualParticipants addObject:contact];
|
||||
|
||||
isMultiUseNameByDisplayName[contact.displayName] = (isMultiUseNameByDisplayName[contact.displayName] ? @(YES) : @(NO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1415,6 +1483,8 @@
|
||||
if ([contact matchedWithPatterns:@[currentSearchText]])
|
||||
{
|
||||
[filteredInvitedParticipants addObject:contact];
|
||||
|
||||
isMultiUseNameByDisplayName[contact.displayName] = (isMultiUseNameByDisplayName[contact.displayName] ? @(YES) : @(NO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1457,6 +1527,8 @@
|
||||
filteredInvitedParticipants = nil;
|
||||
self.isAddParticipantSearchBarEditing = NO;
|
||||
|
||||
isMultiUseNameByDisplayName = nil;
|
||||
|
||||
// Leave search
|
||||
[searchBar resignFirstResponder];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user