diff options
author | ankit-thanekar007 <ankit.thanekar007@gmail.com> | 2021-03-23 12:03:37 -0700 |
---|---|---|
committer | ankit-thanekar007 <ankit.thanekar007@gmail.com> | 2021-03-23 12:06:01 -0700 |
commit | ef3e601ba92a91334245c48b0a8d03e3b1cacc7a (patch) | |
tree | c449c5124a6b527c1c3d6e73d60a9b58226553f6 | |
parent | 81b97d55e0b65e1df51cf65871d69e32ae48b5d0 (diff) |
User not present check
-rw-r--r-- | src/components/moments/MomentPostHeader.tsx | 15 |
1 files changed, 12 insertions, 3 deletions
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<MomentPostHeaderProps> = ({ }) => { 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 ( <View style={[styles.container, style]}> <TouchableOpacity onPress={navigateToProfile} style={styles.header}> |