diff options
author | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-11-02 15:30:43 -0800 |
---|---|---|
committer | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-11-02 15:30:43 -0800 |
commit | dfccfe78feb532381f475365763de113aa4ef7a4 (patch) | |
tree | ad1fec7f36e21825b1ca910f101fdd2f1afe285a /web/react/stores | |
parent | 3128920be991463c4fcfaebb146c7c8f89d680a8 (diff) | |
download | chat-dfccfe78feb532381f475365763de113aa4ef7a4.tar.gz chat-dfccfe78feb532381f475365763de113aa4ef7a4.tar.bz2 chat-dfccfe78feb532381f475365763de113aa4ef7a4.zip |
Added additional checks to channel sorting that sorts by display_name
Diffstat (limited to 'web/react/stores')
-rw-r--r-- | web/react/stores/channel_store.jsx | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/web/react/stores/channel_store.jsx b/web/react/stores/channel_store.jsx index d1f548d50..64aaeb329 100644 --- a/web/react/stores/channel_store.jsx +++ b/web/react/stores/channel_store.jsx @@ -183,11 +183,21 @@ class ChannelStoreClass extends EventEmitter { channels.push(channel); } - channels.sort(function chanSort(a, b) { - if (a.display_name.toLowerCase() < b.display_name.toLowerCase()) { + channels.sort((a, b) => { + let channelADisplayName = ''; + let channelBDisplayName = ''; + + if (a && a.display_name) { + channelADisplayName = a.display_name.toLowerCase(); + } + if (b && b.display_name) { + channelBDisplayName = b.display_name.toLowerCase(); + } + + if (channelADisplayName < channelBDisplayName) { return -1; } - if (a.display_name.toLowerCase() > b.display_name.toLowerCase()) { + if (channelADisplayName > channelBDisplayName) { return 1; } return 0; |