diff --git a/Riot/Modules/StartChat/StartChatViewController.m b/Riot/Modules/StartChat/StartChatViewController.m index 296b38229..055ff1986 100644 --- a/Riot/Modules/StartChat/StartChatViewController.m +++ b/Riot/Modules/StartChat/StartChatViewController.m @@ -322,12 +322,8 @@ } // hide the search bar if a participant is already invited by email - BOOL hideSearchBar = [self participantsAlreadyContainAnEmail]; - self.searchBarHeader.alpha = hideSearchBar ? 0.0f : 1.0f; - self.searchBarHeaderHeightConstraint.constant = hideSearchBar ? 0.0f : 50.0f; - [UIView animateWithDuration:0.2f animations:^{ - [self.view layoutIfNeeded]; - }]; + [self hideSearchBar: [self participantsAlreadyContainAnEmail]]; + } - (BOOL)participantsAlreadyContainAnEmail @@ -363,7 +359,8 @@ } // if it is not a matrix contact, nor a local contact with a MatrixID, and if there is already at least one participant, another participant cannot be added. - if ((contact.matrixIdentifiers.count == 0 && ![MXTools isMatrixUserIdentifier:contact.displayName]) && participants.count > 0) + // bwi: dms can only be created with one participant + if ((contact.matrixIdentifiers.count == 0 && ![MXTools isMatrixUserIdentifier:contact.displayName]) || participants.count > 0) { return NO; } @@ -938,6 +935,11 @@ // Refresh display by leaving search session [self searchBarCancelButtonClicked:_searchBarView]; + + // bwi: if there is already at least one participant, the search bar should be hidden + if (participants.count > 0) { + [self hideSearchBar:true]; + } } } @@ -949,4 +951,15 @@ [self showInviteFriendsFromSourceView:button]; } + +#pragma mark - bwi: hideSearchBar +- (void)hideSearchBar:(BOOL)shouldHide +{ + self.searchBarHeader.alpha = shouldHide ? 0.0f : 1.0f; + self.searchBarHeaderHeightConstraint.constant = shouldHide ? 0.0f : 50.0f; + [UIView animateWithDuration:0.2f animations:^{ + [self.view layoutIfNeeded]; + }]; +} + @end