aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/ProfilePreview.tsx
diff options
context:
space:
mode:
authorAshm Walia <40498934+ashmgarv@users.noreply.github.com>2020-11-09 12:16:44 -0800
committerGitHub <noreply@github.com>2020-11-09 15:16:44 -0500
commitf347ef180ece9235380f2225243beddaececa949 (patch)
tree02ae7739ae16f68fb47a574420c1c497fb5f06ac /src/components/profile/ProfilePreview.tsx
parentd7ed9541f47c22d93c43a32baf3bf33d68d823c8 (diff)
[FOR MASS REVIEW] Multiple contexts(Searched user gets replaced) (#97)
* First commit towards clean code * Tested things * Some final touch * View updates posts * Cleaned up followers / following * You won't believe but it works * Pass avatar uri via props * Small change * Small change * Removed unnecessary jargon Co-authored-by: Ivan Chen <ivan@thetaggid.com>
Diffstat (limited to 'src/components/profile/ProfilePreview.tsx')
-rw-r--r--src/components/profile/ProfilePreview.tsx31
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);
}