From f32b2dfeb230a638b86965518f54314d82fd6063 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Wed, 21 Dec 2022 19:35:34 +0200 Subject: [PATCH] Perform search when hashtag is pressed (#6893) * Perform search when hashtag is pressed * PM feedback review --- app/components/markdown/hashtag/index.tsx | 10 ++++++++-- app/screens/home/search/search.tsx | 8 ++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/components/markdown/hashtag/index.tsx b/app/components/markdown/hashtag/index.tsx index 2090e8073..17b041c54 100644 --- a/app/components/markdown/hashtag/index.tsx +++ b/app/components/markdown/hashtag/index.tsx @@ -2,8 +2,9 @@ // See LICENSE.txt for license information. import React from 'react'; -import {StyleProp, Text, TextStyle} from 'react-native'; +import {DeviceEventEmitter, StyleProp, Text, TextStyle} from 'react-native'; +import {Navigation, Screens} from '@constants'; import {popToRoot, dismissAllModals} from '@screens/navigation'; type HashtagProps = { @@ -17,7 +18,12 @@ const Hashtag = ({hashtag, linkStyle}: HashtagProps) => { await dismissAllModals(); await popToRoot(); - // showSearchModal('#' + hashtag); + DeviceEventEmitter.emit(Navigation.NAVIGATE_TO_TAB, { + screen: Screens.SEARCH, + params: { + searchTerm: hashtag, + }, + }); }; return ( diff --git a/app/screens/home/search/search.tsx b/app/screens/home/search/search.tsx index f10dd256b..c9aadd231 100644 --- a/app/screens/home/search/search.tsx +++ b/app/screens/home/search/search.tsx @@ -109,6 +109,14 @@ const SearchScreen = ({teamId, teams}: Props) => { setSearchTeamId(teamId); }, [teamId]); + useEffect(() => { + if (searchTerm) { + resetToInitial(); + setSearchValue(searchTerm); + handleSearch(searchTeamId, searchTerm); + } + }, [searchTerm]); + const onSnap = (offset: number, animated = true) => { scrollRef.current?.scrollToOffset({offset, animated}); };