From 007dcc5c836f1b368042c530d22f5421610efb7c Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 14 Jan 2021 14:06:07 -0500 Subject: created navigation to comment from notification (#184) --- src/components/profile/ProfilePreview.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/components/profile') diff --git a/src/components/profile/ProfilePreview.tsx b/src/components/profile/ProfilePreview.tsx index 6f008540..134e94cd 100644 --- a/src/components/profile/ProfilePreview.tsx +++ b/src/components/profile/ProfilePreview.tsx @@ -134,21 +134,23 @@ const ProfilePreview: React.FC = ({ } } + const userXId = + loggedInUser.username === user.username ? undefined : user.id; + /** - * Dispatch an event to Fetch the user details - * If the user is already present in store, do not fetch again - * Finally, Navigate to profile of the user selected + * Dispatch an event to Fetch the user details only if we're navigating to + * a userX's profile. + * If the user is already present in store, do not fetch again. + * Finally, Navigate to profile of the user selected. */ - - if (!userXInStore(state, screenType, user.id)) { + if (userXId && !userXInStore(state, screenType, user.id)) { await fetchUserX( dispatch, {userId: user.id, username: user.username}, screenType, ); } - const userXId = - loggedInUser.username === user.username ? undefined : user.id; + navigation.push('Profile', { userXId, screenType, -- cgit v1.2.3-70-g09d2