aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/ProfilePreview.tsx
diff options
context:
space:
mode:
authorTanmay Bhatia <38436012+tbhatia2299@users.noreply.github.com>2020-12-29 11:41:12 -0800
committerGitHub <noreply@github.com>2020-12-29 14:41:12 -0500
commitefaa41884b5aa4b4704380eb3615d3801958a775 (patch)
treebc260b59617af0dd28add0aa51276f36c2c0343f /src/components/profile/ProfilePreview.tsx
parent4383161119549ce2f8f76b24ce6c7dbe421e7e78 (diff)
Made another PR and added code to solve the same purpose as in #152 (#153)
Diffstat (limited to 'src/components/profile/ProfilePreview.tsx')
-rw-r--r--src/components/profile/ProfilePreview.tsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/components/profile/ProfilePreview.tsx b/src/components/profile/ProfilePreview.tsx
index 71fd2a85..cc18e457 100644
--- a/src/components/profile/ProfilePreview.tsx
+++ b/src/components/profile/ProfilePreview.tsx
@@ -19,6 +19,7 @@ import {useSelector, useDispatch, useStore} from 'react-redux';
import {RootState} from '../../store/rootreducer';
import {logout} from '../../store/actions';
import {fetchUserX, userXInStore} from '../../utils';
+import NavigationBar from 'src/routes/tabs';
const NO_USER: UserType = {
userId: '',
username: '',
@@ -38,6 +39,7 @@ interface ProfilePreviewProps extends ViewProps {
previewType: PreviewType;
screenType: ScreenType;
}
+
const ProfilePreview: React.FC<ProfilePreviewProps> = ({
profilePreview: {username, first_name, last_name, id},
previewType,
@@ -156,6 +158,7 @@ const ProfilePreview: React.FC<ProfilePreviewProps> = ({
* 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)) {
await fetchUserX(
dispatch,
@@ -163,10 +166,10 @@ const ProfilePreview: React.FC<ProfilePreviewProps> = ({
screenType,
);
}
+ const userXId = loggedInUser.username === user.username ? undefined : user.id;
navigation.push('Profile', {
- username: user.username,
- userXId: user.id,
- screenType: screenType,
+ userXId,
+ screenType,
});
} catch (e) {
console.log(e);