From 9cc000f6e23d75e826c4468dd5c3977397e58e57 Mon Sep 17 00:00:00 2001
From: Reed Garmsen <rgarmsen2295@gmail.com>
Date: Mon, 2 Nov 2015 16:04:14 -0800
Subject: Functionalized code

---
 web/react/stores/channel_store.jsx | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

(limited to 'web/react/stores/channel_store.jsx')

diff --git a/web/react/stores/channel_store.jsx b/web/react/stores/channel_store.jsx
index 64aaeb329..cc0d0d14b 100644
--- a/web/react/stores/channel_store.jsx
+++ b/web/react/stores/channel_store.jsx
@@ -4,6 +4,7 @@
 var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
 var EventEmitter = require('events').EventEmitter;
 
+var Utils;
 var Constants = require('../utils/constants.jsx');
 var ActionTypes = Constants.ActionTypes;
 
@@ -183,26 +184,11 @@ class ChannelStoreClass extends EventEmitter {
             channels.push(channel);
         }
 
-        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 (channelADisplayName > channelBDisplayName) {
-                return 1;
-            }
-            return 0;
-        });
+        if (!Utils) {
+            Utils = require('../utils/utils.jsx'); //eslint-disable-line global-require
+        }
 
+        channels.sort(Utils.sortByDisplayName);
         this.pStoreChannels(channels);
     }
     pStoreChannels(channels) {
-- 
cgit v1.2.3-1-g7c22

