Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
MM-22326 Fix non-DM/GM autocomplete in search box (#4850)
Browse files Browse the repository at this point in the history
* Fix non-DM/GM autocomplete in search box

* Remove unrelated change
  • Loading branch information
jwilander committed Feb 10, 2020
1 parent 100a9e5 commit a5bb7a7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion components/suggestion/search_channel_provider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ function itemToName(item) {
return item.name;
}

function itemToTerm(item) {
if (item.type === Constants.DM_CHANNEL) {
return '@' + item.display_name;
}
if (item.type === Constants.GM_CHANNEL) {
return '@' + item.display_name.replace(/ /g, '');
}
if (item.type === Constants.OPEN_CHANNEL || item.type === Constants.PRIVATE_CHANNEL) {
return item.name;
}
return item.name;
}

class SearchChannelSuggestion extends Suggestion {
render() {
const {item, isSelection} = this.props;
Expand Down Expand Up @@ -96,7 +109,7 @@ export default class SearchChannelProvider extends Provider {
// MM-12677 When this is migrated this needs to be fixed to pull the user's locale
//
const channels = data.sort(sortChannelsByTypeAndDisplayName.bind(null, 'en'));
const channelNames = channels.map(itemToName);
const channelNames = channels.map(itemToTerm);

resultsCallback({
matchedPretext: channelPrefix,
Expand Down

0 comments on commit a5bb7a7

Please sign in to comment.