Add moment
This commit is contained in:
@@ -3,8 +3,6 @@ import React, { useState, useEffect } from 'react';
|
||||
import { View, ActivityIndicator, StyleSheet, SafeAreaView, FlatList } from 'react-native';
|
||||
import API from './../API.js';
|
||||
import Post from './../components/Post.js';
|
||||
import { Provider as PaperProvider } from 'react-native-paper';
|
||||
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
||||
import NewPost from "./../components/NewPost.js";
|
||||
|
||||
|
||||
@@ -17,7 +15,7 @@ let Profile = ({ navigation, route }) => {
|
||||
let r = await API.getMe();
|
||||
setMeProfile(r);
|
||||
if (route.params && route.params.profileid) {
|
||||
API.getUserProfile(route.params.profileid).then(({profile}) => {
|
||||
API.getUserProfile(route.params.profileid).then(({ profile }) => {
|
||||
navigation.setOptions({ title: profile.firstName + " " + profile.lastName });
|
||||
});
|
||||
API.getPosts(route.params.profileid).then((data) => {
|
||||
@@ -28,32 +26,30 @@ let Profile = ({ navigation, route }) => {
|
||||
}
|
||||
}, [route.params]);
|
||||
const renderPost = (({ item }) => {
|
||||
if (item.nonOrganicType)
|
||||
return (<></>);
|
||||
return (<Post post={item} viewer={Me} />);
|
||||
});
|
||||
|
||||
return (
|
||||
<PaperProvider settings={{
|
||||
icon: props => <MaterialIcons {...props} />,
|
||||
}}>
|
||||
<SafeAreaView style={styles.container}>
|
||||
<View>
|
||||
{Posts.length === 0 && <ActivityIndicator />}
|
||||
{Posts.length !== 0 &&
|
||||
<FlatList
|
||||
data={Posts}
|
||||
renderItem={renderPost}
|
||||
keyExtractor={item => item._id || item.createdAt}
|
||||
ListHeaderComponent={<NewPost newPostCB={(newPost) => setPosts([newPost, ...Posts])} />}
|
||||
refreshing={Posts.length === 0}
|
||||
onRefresh={()=>{
|
||||
API.getPosts(route.params.profileid).then(setPosts);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
</View>
|
||||
<StatusBar style="auto" />
|
||||
</SafeAreaView>
|
||||
</PaperProvider>
|
||||
<SafeAreaView style={styles.container}>
|
||||
<View>
|
||||
{Posts.length === 0 && <ActivityIndicator />}
|
||||
{Posts.length !== 0 &&
|
||||
<FlatList
|
||||
data={Posts}
|
||||
renderItem={renderPost}
|
||||
keyExtractor={item => item._id || item.createdAt}
|
||||
ListHeaderComponent={<NewPost newPostCB={(newPost) => setPosts([newPost, ...Posts])} />}
|
||||
refreshing={Posts.length === 0}
|
||||
onRefresh={() => {
|
||||
API.getPosts(route.params.profileid).then(setPosts);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
</View>
|
||||
<StatusBar style="auto" />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user