summaryrefslogtreecommitdiffstats
path: root/webapp/utils/utils.jsx
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-02-01 08:57:16 +0900
committerenahum <nahumhbl@gmail.com>2017-01-31 20:57:16 -0300
commit9ba968ce3354b1a8ab307ecc4cc785bdee16f914 (patch)
tree1180a7913c326ed66191555d5a21d0643e932b8a /webapp/utils/utils.jsx
parent9369cab56c82629d505d44d572f273df1d396972 (diff)
downloadchat-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/utils/utils.jsx')
-rw-r--r--webapp/utils/utils.jsx22
1 files changed, 6 insertions, 16 deletions
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index 4e8a05075..90e2ad63e 100644
--- a/webapp/utils/utils.jsx
+++ b/webapp/utils/utils.jsx
@@ -1093,25 +1093,15 @@ export function windowHeight() {
return $(window).height();
}
-// Use when sorting multiple channels or teams by their `display_name` field
-export function sortByDisplayName(a, b) {
- let aDisplayName = '';
- let bDisplayName = '';
+// Use when sorting multiple teams by their `display_name` field
+export function sortTeamsByDisplayName(a, b) {
+ const locale = LocalizationStore.getLocale();
- if (a && a.display_name) {
- aDisplayName = a.display_name.toLowerCase();
- }
- if (b && b.display_name) {
- bDisplayName = b.display_name.toLowerCase();
+ if (a.display_name !== b.display_name) {
+ return a.display_name.localeCompare(b.display_name, locale, {numeric: true});
}
- if (aDisplayName < bDisplayName) {
- return -1;
- }
- if (aDisplayName > bDisplayName) {
- return 1;
- }
- return 0;
+ return a.name.localeCompare(b.name, locale, {numeric: true});
}
export function getChannelTerm(channelType) {