Merge pull request #1279 from rgarmsen2295/plt-743

PLT-741/743 Adds additional checks when sorting channels/teams by display name
This commit is contained in:
Joram Wilander
2015-11-04 07:51:49 -05:00
3 changed files with 31 additions and 22 deletions

View File

@@ -1104,3 +1104,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;
}