diff --git a/app/screens/home/search/bottom_sheet_team_list.tsx b/app/screens/home/search/bottom_sheet_team_list.tsx index 063601065..a34518ca3 100644 --- a/app/screens/home/search/bottom_sheet_team_list.tsx +++ b/app/screens/home/search/bottom_sheet_team_list.tsx @@ -1,12 +1,10 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {useCallback, useMemo} from 'react'; -import {useIntl} from 'react-intl'; +import React, {useCallback} from 'react'; import {StyleSheet, View} from 'react-native'; import TeamList from '@components/team_list'; -import {ALL_TEAMS_ID} from '@constants/team'; import {useIsTablet} from '@hooks/device'; import BottomSheetContent from '@screens/bottom_sheet/content'; import {dismissBottomSheet} from '@screens/navigation'; @@ -28,7 +26,6 @@ const styles = StyleSheet.create({ }); export default function BottomSheetTeamList({teams, title, setTeamId, teamId, crossTeamSearchEnabled}: Props) { - const intl = useIntl(); const isTablet = useIsTablet(); const showTitle = !isTablet && Boolean(teams.length); @@ -37,14 +34,6 @@ export default function BottomSheetTeamList({teams, title, setTeamId, teamId, cr dismissBottomSheet(); }, [setTeamId]); - const teamList = useMemo(() => { - const list = [...teams]; - if (crossTeamSearchEnabled) { - list.unshift({id: ALL_TEAMS_ID, displayName: intl.formatMessage({id: 'mobile.search.team.all_teams', defaultMessage: 'All teams'})} as TeamModel); - } - return list; - }, [teams, crossTeamSearchEnabled, intl]); - return ( ({id: ALL_TEAMS_ID, displayName: intl.formatMessage({id: 'mobile.search.team.all_teams', defaultMessage: 'All teams'})} as TeamModel), [intl]); - let selectedTeam = teams.find((t) => t.id === teamId); - if (teamId === ALL_TEAMS_ID) { - selectedTeam = {id: ALL_TEAMS_ID, displayName: intl.formatMessage({id: 'mobile.search.team.all_teams', defaultMessage: 'All teams'})} as TeamModel; - } + const teamList = useMemo(() => { + const list = [...teams]; + if (crossTeamSearchEnabled) { + list.unshift(AllTeams); + } + return list; + }, [teams, crossTeamSearchEnabled, AllTeams]); + + const selectedTeam = teamList.find((t) => t.id === teamId); const title = intl.formatMessage({id: 'mobile.search.team.select', defaultMessage: 'Select a team to search'}); @@ -65,7 +71,7 @@ const TeamPicker = ({setTeamId, teams, teamId, crossTeamSearchEnabled}: Props) = return ( = [ 1, - teams.length ? bottomSheetSnapPoint(Math.min(3, teams.length), ITEM_HEIGHT) + (2 * TITLE_HEIGHT) : NO_TEAMS_HEIGHT, + + // use teams to check if teams is empty + teams.length ? bottomSheetSnapPoint(Math.min(3, teamList.length), ITEM_HEIGHT) + (2 * TITLE_HEIGHT) : NO_TEAMS_HEIGHT, ]; - if (teams.length > 3) { + if (teamList.length > 3) { snapPoints.push('80%'); } @@ -89,7 +97,7 @@ const TeamPicker = ({setTeamId, teams, teamId, crossTeamSearchEnabled}: Props) = theme, title, }); - }, [teams, theme, title, setTeamId, teamId, crossTeamSearchEnabled])); + }, [teams, teamList, theme, title, setTeamId, teamId, crossTeamSearchEnabled])); return ( <>