From 0187200d794d54c1d9954dd86a6a156132dedcac Mon Sep 17 00:00:00 2001 From: ankit-thanekar007 Date: Mon, 22 Mar 2021 12:18:12 -0700 Subject: TMA 642 Touchable Opacity redirection --- src/components/moments/MomentPostHeader.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/components/moments/MomentPostHeader.tsx') diff --git a/src/components/moments/MomentPostHeader.tsx b/src/components/moments/MomentPostHeader.tsx index aad776e8..56b073d6 100644 --- a/src/components/moments/MomentPostHeader.tsx +++ b/src/components/moments/MomentPostHeader.tsx @@ -1,5 +1,11 @@ import React, {useState} from 'react'; -import {StyleSheet, Text, View, ViewProps} from 'react-native'; +import { + StyleSheet, + Text, + TouchableOpacity, + View, + ViewProps, +} from 'react-native'; import {MomentMoreInfoDrawer} from '../profile'; import {loadUserMoments} from '../../store/actions'; import {useDispatch, useSelector} from 'react-redux'; @@ -29,17 +35,23 @@ const MomentPostHeader: React.FC = ({ (state: RootState) => state.user.user, ); const isOwnProfile = loggedInUserName === username; - return ( - + { + navigation.navigate('Profile', { + userXId: isOwnProfile ? undefined : userXId, + screenType, + }); + }} + style={styles.header}> {username} - + Date: Mon, 22 Mar 2021 12:25:39 -0700 Subject: TMA 642 Refactoring --- src/components/moments/MomentPostHeader.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/components/moments/MomentPostHeader.tsx') diff --git a/src/components/moments/MomentPostHeader.tsx b/src/components/moments/MomentPostHeader.tsx index 56b073d6..9abf7fce 100644 --- a/src/components/moments/MomentPostHeader.tsx +++ b/src/components/moments/MomentPostHeader.tsx @@ -30,21 +30,21 @@ const MomentPostHeader: React.FC = ({ }) => { const [drawerVisible, setDrawerVisible] = useState(false); const dispatch = useDispatch(); + const navigation = useNavigation(); const {userId: loggedInUserId, username: loggedInUserName} = useSelector( (state: RootState) => state.user.user, ); const isOwnProfile = loggedInUserName === username; + const navigateToProfile = () => { + navigation.navigate('Profile', { + userXId: isOwnProfile ? undefined : userXId, + screenType, + }); + }; return ( - { - navigation.navigate('Profile', { - userXId: isOwnProfile ? undefined : userXId, - screenType, - }); - }} - style={styles.header}> + Date: Tue, 23 Mar 2021 12:03:37 -0700 Subject: User not present check --- src/components/moments/MomentPostHeader.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/components/moments/MomentPostHeader.tsx') diff --git a/src/components/moments/MomentPostHeader.tsx b/src/components/moments/MomentPostHeader.tsx index 9abf7fce..ff324c4a 100644 --- a/src/components/moments/MomentPostHeader.tsx +++ b/src/components/moments/MomentPostHeader.tsx @@ -8,11 +8,12 @@ import { } from 'react-native'; import {MomentMoreInfoDrawer} from '../profile'; import {loadUserMoments} from '../../store/actions'; -import {useDispatch, useSelector} from 'react-redux'; +import {useDispatch, useSelector, useStore} from 'react-redux'; import {ScreenType} from '../../types'; import Avatar from '../profile/Avatar'; import {useNavigation} from '@react-navigation/native'; import {RootState} from '../../store/rootReducer'; +import {fetchUserX, userXInStore} from '../../utils'; interface MomentPostHeaderProps extends ViewProps { userXId?: string; @@ -30,18 +31,26 @@ const MomentPostHeader: React.FC = ({ }) => { const [drawerVisible, setDrawerVisible] = useState(false); const dispatch = useDispatch(); - + const state: RootState = useStore().getState(); const navigation = useNavigation(); const {userId: loggedInUserId, username: loggedInUserName} = useSelector( (state: RootState) => state.user.user, ); const isOwnProfile = loggedInUserName === username; - const navigateToProfile = () => { + const navigateToProfile = async () => { + if (userXId && !userXInStore(state, screenType, userXId)) { + await fetchUserX( + dispatch, + {userId: userXId, username: username}, + screenType, + ); + } navigation.navigate('Profile', { userXId: isOwnProfile ? undefined : userXId, screenType, }); }; + return ( -- cgit v1.2.3-70-g09d2