forked from Ivasoft/mattermost-mobile
* Fix infinite skeleton in different use cases * Apply suggestions from code review Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * Update app/utils/teams.js Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
17 lines
493 B
JavaScript
17 lines
493 B
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
// @flow
|
|
|
|
export function selectFirstAvailableTeam(teams, primaryTeamName) {
|
|
let defaultTeam;
|
|
if (primaryTeamName) {
|
|
defaultTeam = teams.find((t) => t?.name === primaryTeamName.toLowerCase());
|
|
}
|
|
|
|
if (!defaultTeam) {
|
|
defaultTeam = Object.values(teams).sort((a, b) => a.display_name.localeCompare(b.display_name))[0];
|
|
}
|
|
|
|
return defaultTeam;
|
|
}
|