diff options
Diffstat (limited to 'web/react/components')
-rw-r--r-- | web/react/components/navbar_dropdown.jsx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/web/react/components/navbar_dropdown.jsx b/web/react/components/navbar_dropdown.jsx index f43bdffdf..937e88325 100644 --- a/web/react/components/navbar_dropdown.jsx +++ b/web/react/components/navbar_dropdown.jsx @@ -11,16 +11,24 @@ var AboutBuildModal = require('./about_build_modal.jsx'); var Constants = require('../utils/constants.jsx'); function getStateFromStores() { - let teams = []; - let teamsObject = UserStore.getTeams(); - for (let teamId in teamsObject) { + const teams = []; + const teamsObject = UserStore.getTeams(); + for (const teamId in teamsObject) { if (teamsObject.hasOwnProperty(teamId)) { teams.push(teamsObject[teamId]); } } - teams.sort(function sortByDisplayName(teamA, teamB) { - let teamADisplayName = teamA.display_name.toLowerCase(); - let teamBDisplayName = teamB.display_name.toLowerCase(); + teams.sort((teamA, teamB) => { + let teamADisplayName = ''; + let teamBDisplayName = ''; + + if (teamA && teamA.display_name) { + teamADisplayName = teamA.display_name.toLowerCase(); + } + if (teamB && teamB.display_name) { + teamBDisplayName = teamB.display_name.toLowerCase(); + } + if (teamADisplayName < teamBDisplayName) { return -1; } else if (teamADisplayName > teamBDisplayName) { |