From 6ba996a9e25cc2df05fef1fef2e2f6dd8903625c Mon Sep 17 00:00:00 2001 From: hmhealey Date: Fri, 6 Nov 2015 11:51:10 -0500 Subject: Sorted channel suggestions be type before sorting by name --- web/react/components/search_autocomplete.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'web/react/components') diff --git a/web/react/components/search_autocomplete.jsx b/web/react/components/search_autocomplete.jsx index 736919697..260cbd7bf 100644 --- a/web/react/components/search_autocomplete.jsx +++ b/web/react/components/search_autocomplete.jsx @@ -189,7 +189,16 @@ export default class SearchAutocomplete extends React.Component { channels = channels.filter((channel) => channel.type !== 'D'); } - channels.sort((a, b) => a.name.localeCompare(b.name)); + channels.sort((a, b) => { + // put public channels first and then sort alphabebetically + if (a.type === b.type) { + return a.name.localeCompare(b.name); + } else if (a.type === Constants.OPEN_CHANNEL) { + return -1; + } + + return 1; + }); suggestions = channels; } else if (mode === 'users') { -- cgit v1.2.3-1-g7c22