aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/profile/Content.tsx29
-rw-r--r--src/components/profile/Moment.tsx23
-rw-r--r--src/components/search/SearchResult.tsx6
3 files changed, 33 insertions, 25 deletions
diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx
index d52696a7..0bf66dc7 100644
--- a/src/components/profile/Content.tsx
+++ b/src/components/profile/Content.tsx
@@ -1,10 +1,9 @@
import AsyncStorage from '@react-native-community/async-storage';
import React, {useCallback, useEffect, useState} from 'react';
import {Alert, LayoutChangeEvent, StyleSheet, View} from 'react-native';
-<!-- import {Text} from 'react-native-animatable'; -->
import Animated from 'react-native-reanimated';
-import {AuthContext} from '../../routes/authentication';
-import {MomentType, UserType} from 'src/types';
+import {AuthContext, ProfileContext} from '../../routes/';
+import {MomentType} from 'src/types';
import {defaultMoments, MOMENTS_ENDPOINT} from '../../constants';
import {SCREEN_HEIGHT} from '../../utils';
import TaggsBar from '../taggs/TaggsBar';
@@ -20,8 +19,9 @@ interface ContentProps {
const Content: React.FC<ContentProps> = ({y, isProfileView}) => {
const [profileBodyHeight, setProfileBodyHeight] = useState(0);
- const {newMomentsAvailable, updateMoments} = React.useContext(AuthContext);
-
+ const {newMomentsAvailable, updateMoments, user} = isProfileView
+ ? React.useContext(ProfileContext)
+ : React.useContext(AuthContext);
const [imagesList, setImagesList] = useState<MomentType[]>([]);
const [imagesMap, setImagesMap] = useState<Map<string, MomentType[]>>(
new Map(),
@@ -68,10 +68,10 @@ const Content: React.FC<ContentProps> = ({y, isProfileView}) => {
setImagesList(data);
updateMoments(!newMomentsAvailable);
} else {
- Alert.alert('Could not load moments!');
+ console.log('Could not load moments!');
}
} catch (err) {
- Alert.alert('Could not load moments!');
+ console.log(err);
}
};
@@ -91,19 +91,18 @@ const Content: React.FC<ContentProps> = ({y, isProfileView}) => {
<ProfileCutout>
<ProfileHeader {...{isProfileView}} />
</ProfileCutout>
- <ProfileBody {...{onLayout}} />
- <TaggsBar {...{y, profileBodyHeight}} />
<ProfileBody {...{onLayout, isProfileView}} />
<TaggsBar {...{y, profileBodyHeight, isProfileView}} />
- {!isProfileView ? (
- <View style={styles.momentsContainer}>
+ <View style={styles.momentsContainer}>
{defaultMoments.map((title, index) => (
- <Moment key={index} title={title} images={imagesMap.get(title)} />
+ <Moment
+ key={index}
+ title={title}
+ images={imagesMap.get(title)}
+ isProfileView={isProfileView}
+ />
))}
</View>
- ) : (
- <React.Fragment />
- )}
</Animated.ScrollView>
);
};
diff --git a/src/components/profile/Moment.tsx b/src/components/profile/Moment.tsx
index be7cbfba..1ec5511e 100644
--- a/src/components/profile/Moment.tsx
+++ b/src/components/profile/Moment.tsx
@@ -15,9 +15,10 @@ import {MomentType} from 'src/types';
interface MomentProps {
title: string;
images: MomentType[] | undefined;
+ isProfileView: boolean;
}
-const Moment: React.FC<MomentProps> = ({title, images}) => {
+const Moment: React.FC<MomentProps> = ({title, images, isProfileView}) => {
const navigation = useNavigation();
const navigateToImagePicker = () => {
@@ -36,17 +37,23 @@ const Moment: React.FC<MomentProps> = ({title, images}) => {
});
}
})
- .catch((err) => {Alert.alert('Unable to upload moment!');});
+ .catch((err) => {
+ Alert.alert('Unable to upload moment!');
+ });
};
return (
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.titleText}>{title}</Text>
- <PlusIcon
- width={21}
- height={21}
- onPress={() => navigateToImagePicker()}
- />
+ {!isProfileView ? (
+ <PlusIcon
+ width={21}
+ height={21}
+ onPress={() => navigateToImagePicker()}
+ />
+ ) : (
+ <React.Fragment />
+ )}
</View>
<ScrollView
horizontal
@@ -56,7 +63,7 @@ const Moment: React.FC<MomentProps> = ({title, images}) => {
images.map((imageObj: MomentType) => (
<MomentTile key={imageObj.moment_id} moment={imageObj} />
))}
- {(images === undefined || images.length === 0) && (
+ {(images === undefined || images.length === 0) && !isProfileView && (
<TouchableOpacity onPress={() => navigateToImagePicker()}>
<LinearGradient
colors={['rgba(105, 141, 211, 1)', 'rgba(105, 141, 211, 0.3)']}>
diff --git a/src/components/search/SearchResult.tsx b/src/components/search/SearchResult.tsx
index cc960308..04624004 100644
--- a/src/components/search/SearchResult.tsx
+++ b/src/components/search/SearchResult.tsx
@@ -27,7 +27,7 @@ const SearchResult: React.FC<SearchResultProps> = ({
style,
}) => {
const navigation = useNavigation();
- const {loadProfile} = useContext(ProfileContext);
+ const {loadProfile, updateMoments} = useContext(ProfileContext);
const [avatarURI, setAvatarURI] = useState<string | null>(null);
const [user, setUser] = useState<UserType>(NO_USER);
useEffect(() => {
@@ -100,10 +100,12 @@ const SearchResult: React.FC<SearchResultProps> = ({
recentlySearchedList = [user];
}
- //Load user profile and navigate to ProfileView
+ //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.
//Not sure if we should make this call before caching the search results ??
loadProfile(user.id, user.username);
+ updateMoments(true);
navigation.navigate('Profile', {
isProfileView: true,
});