aboutsummaryrefslogtreecommitdiff
path: root/src/components/search/SearchResultCell.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-03-08 19:54:42 -0500
committerIvan Chen <ivan@tagg.id>2021-03-08 19:54:42 -0500
commitf899dc058f90813c5ae71e55407a11e6ca13e1ed (patch)
tree84c93e869fab6d434d6709dc1d471c6e588c4e4e /src/components/search/SearchResultCell.tsx
parent8837ea74dbff9cf455cd7cb092767e51de3900f8 (diff)
parentd77f43663fbe409b011b5509bcbff3d07f8ded55 (diff)
Merge branch 'master' into tma684-search-for-badges
# Conflicts: # src/components/search/SearchResultCell.tsx # src/components/search/SearchResultList.tsx
Diffstat (limited to 'src/components/search/SearchResultCell.tsx')
-rw-r--r--src/components/search/SearchResultCell.tsx35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/components/search/SearchResultCell.tsx b/src/components/search/SearchResultCell.tsx
index b6ce55d0..5cba6d2f 100644
--- a/src/components/search/SearchResultCell.tsx
+++ b/src/components/search/SearchResultCell.tsx
@@ -6,7 +6,12 @@ import {useDispatch, useStore} from 'react-redux';
import {ERROR_UNABLE_TO_VIEW_PROFILE} from '../../constants/strings';
import {loadImageFromURL} from '../../services';
import {RootState} from '../../store/rootReducer';
-import {ProfilePreviewType, ScreenType, UserType} from '../../types';
+import {
+ ProfilePreviewType,
+ ScreenType,
+ UserType,
+ CategoryPreviewType,
+} from '../../types';
import {normalize, SCREEN_WIDTH} from '../../utils';
import {
addUserToRecentlyViewed,
@@ -14,6 +19,7 @@ import {
defaultUserProfile,
fetchUserX,
userXInStore,
+ addCategoryToRecentlySearched,
} from '../../utils/users';
interface SearchResults {
@@ -68,7 +74,7 @@ const SearchResultsCell: React.FC<SearchResults> = ({
return;
}
- await addUserToRecentlyViewed({
+ addUserToRecentlyViewed({
id,
first_name,
last_name,
@@ -101,6 +107,18 @@ const SearchResultsCell: React.FC<SearchResults> = ({
}
};
+ /*
+ * Save selected category in recently-searched categories and navigate to its Discover screen.
+ */
+ const onPressCategory = async () => {
+ const categoryObj: CategoryPreviewType = {name, category};
+ addCategoryToRecentlySearched(categoryObj);
+ navigation.navigate('DiscoverUsers', {
+ type,
+ searchCategory: {id, name},
+ });
+ };
+
const userCell = () => {
return (
<TouchableOpacity
@@ -131,14 +149,7 @@ const SearchResultsCell: React.FC<SearchResults> = ({
const categoryCell = () => {
return (
- <TouchableOpacity
- style={styles.cellContainer}
- onPress={() =>
- navigation.navigate('DiscoverUsers', {
- type,
- searchCategory: {id, name},
- })
- }>
+ <TouchableOpacity style={styles.cellContainer} onPress={onPressCategory}>
<View style={[styles.imageContainer, styles.categoryBackground]}>
<Image
resizeMode="contain"
@@ -159,8 +170,8 @@ const SearchResultsCell: React.FC<SearchResults> = ({
const styles = StyleSheet.create({
cellContainer: {
flexDirection: 'row',
- marginHorizontal: SCREEN_WIDTH * 0.08,
- marginBottom: SCREEN_WIDTH * 0.08,
+ paddingHorizontal: 25,
+ paddingVertical: 15,
},
imageContainer: {
width: SCREEN_WIDTH * 0.112,