Add moment
This commit is contained in:
@@ -4,6 +4,7 @@ import { View, Text, StyleSheet, SafeAreaView, FlatList } from 'react-native';
|
|||||||
import { Card } from 'react-native-paper';
|
import { Card } from 'react-native-paper';
|
||||||
import API from './../API.js';
|
import API from './../API.js';
|
||||||
import Post from './../components/Post.js';
|
import Post from './../components/Post.js';
|
||||||
|
import Moment from 'moment';
|
||||||
|
|
||||||
|
|
||||||
let LoadPost = ({ postid, viewer }) => {
|
let LoadPost = ({ postid, viewer }) => {
|
||||||
@@ -24,13 +25,16 @@ let Notifications = ({ navigation, route }) => {
|
|||||||
}, [route.params]);
|
}, [route.params]);
|
||||||
const renderNotification = (({ item }) => {
|
const renderNotification = (({ item }) => {
|
||||||
//return (<LoadPost postid={item.postid} viewer={Me} />);
|
//return (<LoadPost postid={item.postid} viewer={Me} />);
|
||||||
const gotToPost = ()=>{
|
const gotToPost = () => {
|
||||||
navigation.navigate('SinglePost', {postid: item.postid, viewer: Me});
|
navigation.navigate('SinglePost', { postid: item.postid, viewer: Me });
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Card style={{margin: 3}} onPress={gotToPost}>
|
<Card style={{ margin: 3 }} onPress={gotToPost}>
|
||||||
<Card.Content>
|
<Card.Content>
|
||||||
<Text>{item.body}</Text>
|
<Text>{item.body}</Text>
|
||||||
|
<Text style={{ fontWeight: 'normal', fontSize: 12 }}>
|
||||||
|
{" " + Moment(item.ts).fromNow()}
|
||||||
|
</Text>
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import { View, ActivityIndicator, StyleSheet, SafeAreaView, FlatList } from 'react-native';
|
import { View, ActivityIndicator, StyleSheet, SafeAreaView, FlatList } from 'react-native';
|
||||||
import API from './../API.js';
|
import API from './../API.js';
|
||||||
import Post from './../components/Post.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";
|
import NewPost from "./../components/NewPost.js";
|
||||||
|
|
||||||
|
|
||||||
@@ -17,7 +15,7 @@ let Profile = ({ navigation, route }) => {
|
|||||||
let r = await API.getMe();
|
let r = await API.getMe();
|
||||||
setMeProfile(r);
|
setMeProfile(r);
|
||||||
if (route.params && route.params.profileid) {
|
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 });
|
navigation.setOptions({ title: profile.firstName + " " + profile.lastName });
|
||||||
});
|
});
|
||||||
API.getPosts(route.params.profileid).then((data) => {
|
API.getPosts(route.params.profileid).then((data) => {
|
||||||
@@ -28,32 +26,30 @@ let Profile = ({ navigation, route }) => {
|
|||||||
}
|
}
|
||||||
}, [route.params]);
|
}, [route.params]);
|
||||||
const renderPost = (({ item }) => {
|
const renderPost = (({ item }) => {
|
||||||
|
if (item.nonOrganicType)
|
||||||
|
return (<></>);
|
||||||
return (<Post post={item} viewer={Me} />);
|
return (<Post post={item} viewer={Me} />);
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PaperProvider settings={{
|
<SafeAreaView style={styles.container}>
|
||||||
icon: props => <MaterialIcons {...props} />,
|
<View>
|
||||||
}}>
|
{Posts.length === 0 && <ActivityIndicator />}
|
||||||
<SafeAreaView style={styles.container}>
|
{Posts.length !== 0 &&
|
||||||
<View>
|
<FlatList
|
||||||
{Posts.length === 0 && <ActivityIndicator />}
|
data={Posts}
|
||||||
{Posts.length !== 0 &&
|
renderItem={renderPost}
|
||||||
<FlatList
|
keyExtractor={item => item._id || item.createdAt}
|
||||||
data={Posts}
|
ListHeaderComponent={<NewPost newPostCB={(newPost) => setPosts([newPost, ...Posts])} />}
|
||||||
renderItem={renderPost}
|
refreshing={Posts.length === 0}
|
||||||
keyExtractor={item => item._id || item.createdAt}
|
onRefresh={() => {
|
||||||
ListHeaderComponent={<NewPost newPostCB={(newPost) => setPosts([newPost, ...Posts])} />}
|
API.getPosts(route.params.profileid).then(setPosts);
|
||||||
refreshing={Posts.length === 0}
|
}}
|
||||||
onRefresh={()=>{
|
/>
|
||||||
API.getPosts(route.params.profileid).then(setPosts);
|
}
|
||||||
}}
|
</View>
|
||||||
/>
|
<StatusBar style="auto" />
|
||||||
}
|
</SafeAreaView>
|
||||||
</View>
|
|
||||||
<StatusBar style="auto" />
|
|
||||||
</SafeAreaView>
|
|
||||||
</PaperProvider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import UserName from './UserName.js';
|
|||||||
import Media from './Media.js';
|
import Media from './Media.js';
|
||||||
import Comment from "./Comment";
|
import Comment from "./Comment";
|
||||||
import NewComment from './NewComment.js';
|
import NewComment from './NewComment.js';
|
||||||
|
import Moment from 'moment';
|
||||||
|
|
||||||
|
|
||||||
let Post = (props) => {
|
let Post = (props) => {
|
||||||
@@ -58,12 +59,15 @@ let Post = (props) => {
|
|||||||
<Text style={styles.userName}>
|
<Text style={styles.userName}>
|
||||||
<UserName profileid={post.profileid} />
|
<UserName profileid={post.profileid} />
|
||||||
{toProfileText}
|
{toProfileText}
|
||||||
|
<Text style={{ fontWeight: 'normal', fontSize: 12 }}>
|
||||||
|
{" " + Moment(post.createdAt).fromNow()}
|
||||||
|
</Text>
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={{ fontSize: 18 }}>{cleanContent}</Text>
|
<Text style={{ fontSize: 18 }}>{cleanContent}</Text>
|
||||||
<Media content={post.content} />
|
<Media content={post.content} />
|
||||||
</View> :
|
</View> :
|
||||||
<View>
|
<View>
|
||||||
<Chip icon="new-releases" style={{width:100}} >News</Chip>
|
<Chip icon="new-releases" style={{ width: 100 }} >News</Chip>
|
||||||
<Text style={{ fontSize: 18 }}>{cleanContent}</Text>
|
<Text style={{ fontSize: 18 }}>{cleanContent}</Text>
|
||||||
</View>
|
</View>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"@react-navigation/native-stack": "^6.5.0",
|
"@react-navigation/native-stack": "^6.5.0",
|
||||||
"expo": "~43.0.2",
|
"expo": "~43.0.2",
|
||||||
"expo-status-bar": "~1.1.0",
|
"expo-status-bar": "~1.1.0",
|
||||||
|
"moment": "^2.29.1",
|
||||||
"react": "17.0.1",
|
"react": "17.0.1",
|
||||||
"react-dom": "17.0.1",
|
"react-dom": "17.0.1",
|
||||||
"react-google-material-icons": "^1.0.4",
|
"react-google-material-icons": "^1.0.4",
|
||||||
|
|||||||
Reference in New Issue
Block a user