diff options
Diffstat (limited to 'src/components/profile/ProfilePreview.tsx')
-rw-r--r-- | src/components/profile/ProfilePreview.tsx | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/src/components/profile/ProfilePreview.tsx b/src/components/profile/ProfilePreview.tsx index 7bbc3fb6..9c953e7d 100644 --- a/src/components/profile/ProfilePreview.tsx +++ b/src/components/profile/ProfilePreview.tsx @@ -13,7 +13,6 @@ import RNFetchBlob from 'rn-fetch-blob'; import AsyncStorage from '@react-native-community/async-storage'; import {AVATAR_PHOTO_ENDPOINT} from '../../constants'; import {UserType} from '../../types'; -import {ProfileContext} from '../../routes/viewProfile'; const NO_USER: UserType = { userId: '', username: '', @@ -25,8 +24,8 @@ const NO_USER: UserType = { * If isComment is true then it means that we are not displaying this tile as a part of search results. * And hence we do not cache the search results. * On the other hand, if isComment is false, then we should update the search cache. (This cache needs to be revamped to clear outdated results.) - * In either case, we load the ProfileContext with data and set the getNewMoments flag to true (Which ensures that everything that needs to be displayed on a user's profile is set). - * Finally, We navigate to Profile if we are on the Search Stack. Else we navigate to ProfileView. + * In either case, we update the userBeingVisited in our AuthContext (Which can be used to make api calls later on to fetch user specific data). + * Finally, We navigate to Profile. */ interface ProfilePreviewProps extends ViewProps { @@ -39,9 +38,6 @@ const ProfilePreview: React.FC<ProfilePreviewProps> = ({ style, }) => { const navigation = useNavigation(); - const {loadProfile, updateMoments, updateFollowers} = useContext( - ProfileContext, - ); const [avatarURI, setAvatarURI] = useState<string | null>(null); const [user, setUser] = useState<UserType>(NO_USER); useEffect(() => { @@ -128,21 +124,14 @@ const ProfilePreview: React.FC<ProfilePreviewProps> = ({ } } - //Load user profile and set new moments to true, navigate to Profile - //Load user profile makes sure that we actually load profile of the user the logged in user want to view - //Set new moments to true makes sure that we download the moment for the user being viewed again. - loadProfile(user.id, user.username); - updateMoments(true); - updateFollowers(true); - if (!isComment) { - navigation.push('Profile', { - isProfileView: true, - }); - } else { - navigation.push('ProfileView', { - isProfileView: true, - }); - } + /** + * Navigate to profile of the user selected + */ + navigation.push('Profile', { + isProfileView: true, + username: user.username, + userId: user.id, + }); } catch (e) { console.log(e); } |