From efaa41884b5aa4b4704380eb3615d3801958a775 Mon Sep 17 00:00:00 2001 From: Tanmay Bhatia <38436012+tbhatia2299@users.noreply.github.com> Date: Tue, 29 Dec 2020 11:41:12 -0800 Subject: Made another PR and added code to solve the same purpose as in #152 (#153) --- src/components/profile/Content.tsx | 6 ------ src/components/profile/ProfileBody.tsx | 6 +----- src/components/profile/ProfilePreview.tsx | 9 ++++++--- 3 files changed, 7 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx index 71e4f195..17713ea3 100644 --- a/src/components/profile/Content.tsx +++ b/src/components/profile/Content.tsx @@ -119,11 +119,6 @@ const Content: React.FC = ({y, userXId, screenType}) => { }); }, []); - /** - * If own profile is being viewed then do not show the follow button. - */ - const isOwnProfile = loggedInUser.username === user.username; - const onLayout = (e: LayoutChangeEvent) => { const {height} = e.nativeEvent.layout; setProfileBodyHeight(height); @@ -283,7 +278,6 @@ const Content: React.FC = ({y, userXId, screenType}) => { onLayout, userXId, screenType, - isOwnProfile, isFollowed, handleFollowUnfollow, isBlocked, diff --git a/src/components/profile/ProfileBody.tsx b/src/components/profile/ProfileBody.tsx index 49ee74ee..85634daa 100644 --- a/src/components/profile/ProfileBody.tsx +++ b/src/components/profile/ProfileBody.tsx @@ -11,7 +11,6 @@ interface ProfileBodyProps { onLayout: (event: LayoutChangeEvent) => void; isFollowed: boolean; isBlocked: boolean; - isOwnProfile: boolean; handleFollowUnfollow: Function; handleBlockUnblock: Function; userXId: string | undefined; @@ -21,7 +20,6 @@ const ProfileBody: React.FC = ({ onLayout, isFollowed, isBlocked, - isOwnProfile, handleFollowUnfollow, handleBlockUnblock, userXId, @@ -50,7 +48,7 @@ const ProfileBody: React.FC = ({ ); }}>{`${website}`} )} - {userXId && !isOwnProfile ? ( + {userXId && ( {!isBlocked && ( = ({ buttonType={TOGGLE_BUTTON_TYPE.BLOCK_UNBLOCK} /> - ) : ( - <> )} ); 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 = ({ profilePreview: {username, first_name, last_name, id}, previewType, @@ -156,6 +158,7 @@ const ProfilePreview: React.FC = ({ * 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 = ({ 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); -- cgit v1.2.3-70-g09d2