diff options
author | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-11-02 16:04:14 -0800 |
---|---|---|
committer | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-11-02 16:21:50 -0800 |
commit | 9cc000f6e23d75e826c4468dd5c3977397e58e57 (patch) | |
tree | 6976121fa6dae9f5d2f11ee227e4e5784f1b9d59 /web/react/utils | |
parent | dfccfe78feb532381f475365763de113aa4ef7a4 (diff) | |
download | chat-9cc000f6e23d75e826c4468dd5c3977397e58e57.tar.gz chat-9cc000f6e23d75e826c4468dd5c3977397e58e57.tar.bz2 chat-9cc000f6e23d75e826c4468dd5c3977397e58e57.zip |
Functionalized code
Diffstat (limited to 'web/react/utils')
-rw-r--r-- | web/react/utils/utils.jsx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 296307bc6..35c6e29b6 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -1090,3 +1090,24 @@ export function openDirectChannelToUser(user, successCb, errorCb) { ); } } + +// Use when sorting multiple channels or teams by their `display_name` field +export function sortByDisplayName(a, b) { + let aDisplayName = ''; + let bDisplayName = ''; + + if (a && a.display_name) { + aDisplayName = a.display_name.toLowerCase(); + } + if (b && b.display_name) { + bDisplayName = b.display_name.toLowerCase(); + } + + if (aDisplayName < bDisplayName) { + return -1; + } + if (aDisplayName > bDisplayName) { + return 1; + } + return 0; +} |