Perform search when hashtag is pressed (#6893)

* Perform search when hashtag is pressed

* PM feedback review
This commit is contained in:
Elias Nahum 2022-12-21 19:35:34 +02:00 committed by GitHub
parent 92ca1e3704
commit f32b2dfeb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View file

@ -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 (

View file

@ -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});
};