Skip to content

Commit

Permalink
people auto complete: Also send user ID for users having same full name.
Browse files Browse the repository at this point in the history
Previously, our @-mention autocomplete had a bug, wherein it
failed to correctly mention the specific user if more than one
users had the same full name.

Now, if more than one users have the same full name, we send the
user ID as well to ensure that the correct user is @-mentioned.

The user ID is not sent for every @-mention to ensure the
behaviour is consistent with the web app, i.e., we send it
only in case of ambiguity.

See the `get_mention_syntax` function in `static/js/people.js`
in the webapp source for the origin of this syntax.
  • Loading branch information
agrawal-d authored and chrisbobbe committed Jul 2, 2020
1 parent ba6b6b3 commit ebcaae2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/autocomplete/PeopleAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ class PeopleAutocomplete extends PureComponent<Props> {
const { users, onAutocomplete } = this.props;
const user = users.find(x => x.email === email);
if (user) {
// If another user with the same full name is found, we send the
// user ID as well, to ensure the mentioned user is uniquely identified.
if (users.find(x => x.full_name === user.full_name && x.user_id !== user.user_id)) {
// See the `get_mention_syntax` function in
// `static/js/people.js` in the webapp.
onAutocomplete(`**${user.full_name}|${user.user_id}**`);
return;
}
onAutocomplete(`**${user.full_name}**`);
}
};
Expand Down

0 comments on commit ebcaae2

Please sign in to comment.