From 0187200d794d54c1d9954dd86a6a156132dedcac Mon Sep 17 00:00:00 2001
From: ankit-thanekar007 <ankit.thanekar007@gmail.com>
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<MomentPostHeaderProps> = ({
     (state: RootState) => state.user.user,
   );
   const isOwnProfile = loggedInUserName === username;
-
   return (
     <View style={[styles.container, style]}>
-      <View style={styles.header}>
+      <TouchableOpacity
+        onPress={() => {
+          navigation.navigate('Profile', {
+            userXId: isOwnProfile ? undefined : userXId,
+            screenType,
+          });
+        }}
+        style={styles.header}>
         <Avatar
           style={styles.avatar}
           userXId={userXId}
           screenType={screenType}
         />
         <Text style={styles.headerText}>{username}</Text>
-      </View>
+      </TouchableOpacity>
       <MomentMoreInfoDrawer
         isOpen={drawerVisible}
         setIsOpen={setDrawerVisible}
-- 
cgit v1.2.3-70-g09d2


From b2c3242021348274fc518a7e716dc9e0d6d1586d Mon Sep 17 00:00:00 2001
From: ankit-thanekar007 <ankit.thanekar007@gmail.com>
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<MomentPostHeaderProps> = ({
 }) => {
   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 (
     <View style={[styles.container, style]}>
-      <TouchableOpacity
-        onPress={() => {
-          navigation.navigate('Profile', {
-            userXId: isOwnProfile ? undefined : userXId,
-            screenType,
-          });
-        }}
-        style={styles.header}>
+      <TouchableOpacity onPress={navigateToProfile} style={styles.header}>
         <Avatar
           style={styles.avatar}
           userXId={userXId}
-- 
cgit v1.2.3-70-g09d2


From ef3e601ba92a91334245c48b0a8d03e3b1cacc7a Mon Sep 17 00:00:00 2001
From: ankit-thanekar007 <ankit.thanekar007@gmail.com>
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<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}>
-- 
cgit v1.2.3-70-g09d2

