diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-02-01 08:57:16 +0900 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-01-31 20:57:16 -0300 |
commit | 9ba968ce3354b1a8ab307ecc4cc785bdee16f914 (patch) | |
tree | 1180a7913c326ed66191555d5a21d0643e932b8a /webapp/components/suggestion/switch_channel_provider.jsx | |
parent | 9369cab56c82629d505d44d572f273df1d396972 (diff) | |
download | chat-9ba968ce3354b1a8ab307ecc4cc785bdee16f914.tar.gz chat-9ba968ce3354b1a8ab307ecc4cc785bdee16f914.tar.bz2 chat-9ba968ce3354b1a8ab307ecc4cc785bdee16f914.zip |
Use consistent Display Name sorting code throughout the webapp #5159 (#5213)
* Use consistent Display Name sorting code throughout the webapp #5159
* fixed broken sorting of teams and channels
Diffstat (limited to 'webapp/components/suggestion/switch_channel_provider.jsx')
-rw-r--r-- | webapp/components/suggestion/switch_channel_provider.jsx | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/webapp/components/suggestion/switch_channel_provider.jsx b/webapp/components/suggestion/switch_channel_provider.jsx index 0bc30a79f..3b7bec319 100644 --- a/webapp/components/suggestion/switch_channel_provider.jsx +++ b/webapp/components/suggestion/switch_channel_provider.jsx @@ -12,6 +12,7 @@ import Client from 'client/web_client.jsx'; import AppDispatcher from 'dispatcher/app_dispatcher.jsx'; import {Constants, ActionTypes} from 'utils/constants.jsx'; import * as Utils from 'utils/utils.jsx'; +import {sortChannelsByDisplayName} from 'utils/channel_utils.jsx'; import React from 'react'; @@ -105,19 +106,9 @@ export default class SwitchChannelProvider extends Provider { userMap[user.id] = user; } - channels.sort((a, b) => { - if (a.display_name === b.display_name) { - if (a.type !== Constants.DM_CHANNEL && b.type === Constants.DM_CHANNEL) { - return -1; - } else if (a.type === Constants.DM_CHANNEL && b.type !== Constants.DM_CHANNEL) { - return 1; - } - return a.name.localeCompare(b.name); - } - return a.display_name.localeCompare(b.display_name); - }); - - const channelNames = channels.map((channel) => channel.name); + const channelNames = channels. + sort(sortChannelsByDisplayName). + map((channel) => channel.name); AppDispatcher.handleServerAction({ type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS, |