aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/moments/MomentPostHeader.tsx15
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}>