diff --git a/app/screens/home/search/recent_searches/index.tsx b/app/screens/home/search/initial/index.tsx similarity index 93% rename from app/screens/home/search/recent_searches/index.tsx rename to app/screens/home/search/initial/index.tsx index 608e4a57f..c68d082d7 100644 --- a/app/screens/home/search/recent_searches/index.tsx +++ b/app/screens/home/search/initial/index.tsx @@ -1,6 +1,5 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. - import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider'; import withObservables from '@nozbe/with-observables'; import compose from 'lodash/fp/compose'; @@ -9,7 +8,7 @@ import {switchMap, distinctUntilChanged} from 'rxjs/operators'; import {observeTeam, queryTeamSearchHistoryByTeamId} from '@queries/servers/team'; -import RecentSearches from './recent_searches'; +import Initial from './initial'; import type {WithDatabaseArgs} from '@typings/database/database'; @@ -30,4 +29,5 @@ const enhance = withObservables(['teamId'], ({database, teamId}: EnhanceProps) = export default compose( withDatabase, enhance, -)(RecentSearches); +)(Initial); + diff --git a/app/screens/home/search/initial/initial.tsx b/app/screens/home/search/initial/initial.tsx new file mode 100644 index 000000000..d02dcd94e --- /dev/null +++ b/app/screens/home/search/initial/initial.tsx @@ -0,0 +1,41 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; + +import Modifiers from './modifiers'; +import RecentSearches from './recent_searches'; + +import type TeamSearchHistoryModel from '@typings/database/models/servers/team_search_history'; + +type Props = { + recentSearches: TeamSearchHistoryModel[]; + searchValue?: string; + setRecentValue: (value: string) => void; + setSearchValue: (value: string) => void; + setTeamId: (value: string) => void; + teamId: string; + teamName: string; +} + +const Initial = ({setRecentValue, recentSearches, searchValue, teamId, teamName, setTeamId, setSearchValue}: Props) => { + return ( + <> + + {Boolean(recentSearches.length) && + + } + + ); +}; + +export default Initial; diff --git a/app/screens/home/search/modifiers/index.tsx b/app/screens/home/search/initial/modifiers/index.tsx similarity index 98% rename from app/screens/home/search/modifiers/index.tsx rename to app/screens/home/search/initial/modifiers/index.tsx index dd2ce0cd1..b0c42a520 100644 --- a/app/screens/home/search/modifiers/index.tsx +++ b/app/screens/home/search/initial/modifiers/index.tsx @@ -8,11 +8,10 @@ import Animated, {useSharedValue, useAnimatedStyle, withTiming} from 'react-nati import FormattedText from '@components/formatted_text'; import {useTheme} from '@context/theme'; +import TeamPickerIcon from '@screens/home/search/team_picker_icon'; import {makeStyleSheetFromTheme} from '@utils/theme'; import {typography} from '@utils/typography'; -import TeamPickerIcon from '../team_picker_icon'; - import Modifier, {ModifierItem} from './modifier'; import ShowMoreButton from './show_more'; diff --git a/app/screens/home/search/modifiers/modifier.tsx b/app/screens/home/search/initial/modifiers/modifier.tsx similarity index 100% rename from app/screens/home/search/modifiers/modifier.tsx rename to app/screens/home/search/initial/modifiers/modifier.tsx diff --git a/app/screens/home/search/modifiers/show_more.tsx b/app/screens/home/search/initial/modifiers/show_more.tsx similarity index 100% rename from app/screens/home/search/modifiers/show_more.tsx rename to app/screens/home/search/initial/modifiers/show_more.tsx diff --git a/app/screens/home/search/recent_searches/recent_searches.tsx b/app/screens/home/search/initial/recent_searches/index.tsx similarity index 100% rename from app/screens/home/search/recent_searches/recent_searches.tsx rename to app/screens/home/search/initial/recent_searches/index.tsx diff --git a/app/screens/home/search/recent_searches/recent_item.tsx b/app/screens/home/search/initial/recent_searches/recent_item.tsx similarity index 98% rename from app/screens/home/search/recent_searches/recent_item.tsx rename to app/screens/home/search/initial/recent_searches/recent_item.tsx index bd2de729e..d440b6181 100644 --- a/app/screens/home/search/recent_searches/recent_item.tsx +++ b/app/screens/home/search/initial/recent_searches/recent_item.tsx @@ -56,7 +56,7 @@ const RecentItem = ({item, setRecentValue}: Props) => { const handleRemove = useCallback(async () => { await removeSearchFromTeamSearchHistory(serverUrl, item.id); - }, [item.id]); + }, [item.id, serverUrl]); return ( { /> ), [theme, scrollPaddingTop]); - const modifiersComponent = useMemo(() => ( - <> - - - + const initialComponent = useMemo(() => ( + ), [searchValue, searchTeamId, handleRecentSearch]); const resultsComponent = useMemo(() => ( @@ -187,12 +181,12 @@ const SearchScreen = ({teamId}: Props) => { return loadingComponent; } if (!showResults) { - return modifiersComponent; + return initialComponent; } return resultsComponent; }, [ loading && loadingComponent, - !loading && !showResults && modifiersComponent, + !loading && !showResults && initialComponent, !loading && showResults && resultsComponent, ]);