diff --git a/Views/Profile.js b/Views/Profile.js
index cf4305f..9f5310e 100644
--- a/Views/Profile.js
+++ b/Views/Profile.js
@@ -4,22 +4,50 @@ import { View, ActivityIndicator, StyleSheet, SafeAreaView, FlatList } from 'rea
import API from './../API.js';
import Post from './../components/Post.js';
import NewPost from "./../components/NewPost.js";
+import ProfileHeader from '../components/ProfileHeader.js';
+const storeProfilePosts = async (profileid, value) => {
+ try {
+ const jsonValue = JSON.stringify(value)
+ await AsyncStorage.setItem('profile_' + profileid, jsonValue)
+ } catch (e) {
+ }
+}
+const getProfilePosts = async (profileid) => {
+ try {
+ const value = await AsyncStorage.getItem('profile_' + profileid)
+ if (value !== null) {
+ return JSON.parse(value);
+ }
+ return [];
+ } catch (e) {
+ return [];
+ }
+}
let Profile = ({ navigation, route }) => {
let [Me, setMeProfile] = useState({});
let [Posts, setPosts] = useState([]);
+ let [profile, setProfile] = useState({});
+
useEffect(async () => {
setPosts([]);
let r = await API.getMe();
setMeProfile(r);
if (route.params && route.params.profileid) {
- API.getUserProfile(route.params.profileid).then(({ profile }) => {
+ console.log('Loading Cache Profile:' + route.params.profileid);
+ getProfilePosts(route.params.profileid).then(setPosts);
+ console.log('Loaded Cache Profile:' + route.params.profileid);
+ API.getUserProfile(route.params.profileid).then((profileObj) => {
+ let profile = profileObj.profile
+ setProfile(profileObj);
navigation.setOptions({ title: profile.firstName + " " + profile.lastName });
});
API.getPosts(route.params.profileid).then((data) => {
setPosts(data);
+ storeProfilePosts(route.params.profileid, data);
+ console.log('Store Cache Profile:' + route.params.profileid);
});
} else {
navigation.navigate('Feed')
@@ -30,6 +58,12 @@ let Profile = ({ navigation, route }) => {
return (<>>);
return ();
});
+ const header = (
+
+
+ setPosts([newPost, ...Posts])} />
+
+ )
return (
@@ -40,7 +74,7 @@ let Profile = ({ navigation, route }) => {
data={Posts}
renderItem={renderPost}
keyExtractor={item => item._id || item.createdAt}
- ListHeaderComponent={ setPosts([newPost, ...Posts])} />}
+ ListHeaderComponent={header}
refreshing={Posts.length === 0}
onRefresh={() => {
API.getPosts(route.params.profileid).then(setPosts);
diff --git a/components/Media.js b/components/Media.js
index a51ba1f..5f656a6 100644
--- a/components/Media.js
+++ b/components/Media.js
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
import { Text, View, ScrollView, Image, StyleSheet } from 'react-native';
import API from './../API.js';
import VideoPlayer from './VideoPlayer.js';
+import VimeoPlayer from './VimeoPlayer.js';
const videoIdF = (content) => {
let vimeoTag = content.match(/@vimeo:[0-9]+/);
@@ -39,13 +40,13 @@ let Media = (props) => {
const imageStyle = imagesTag.length == 1 ? styles.image : styles.multipleImage;
const videosId = videoIdF(props.content);
let [videosFiles, setVideosFiles] = useState([]);
- useEffect(async ()=>{
- if(!videosId[1]) return 0;
+ useEffect(async () => {
+ if (!videosId[1]) return 0;
let videoObj = await API.getVideo(videosId[1]);
- setVideosFiles(videoObj.files);
+ setVideosFiles(videoObj.files || []);
}, [props.content])
- //const vimeo = videosId.length ? : undefined;
- const vimeo = videosFiles.length ? : null;
+ const vimeo = videosFiles.length ? :
+ (videosId.length ? : <>>);
return (
diff --git a/components/Post.js b/components/Post.js
index a008885..77abf53 100644
--- a/components/Post.js
+++ b/components/Post.js
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
-import { Text, ScrollView, FlatList, StyleSheet, View } from 'react-native';
+import { Text, ScrollView, FlatList, StyleSheet, View, Linking } from 'react-native';
+import Hyperlink from 'react-native-hyperlink'
import { Avatar, Button, Card, Title, Chip } from 'react-native-paper';
import API from './../API.js';
import UserName from './UserName.js';
@@ -8,7 +9,6 @@ import Comment from "./Comment";
import NewComment from './NewComment.js';
import Moment from 'moment';
-
let Post = (props) => {
const viewer = props.viewer;
let [showCommentsB, changeshowCommentsB] = useState(false);
@@ -18,6 +18,7 @@ let Post = (props) => {
let toProfileText = post.toProfile && post.toProfile !== post.profileid ?
{">"} : undefined;
let cleanContent = post.content.replace(/@[A-z]+:.+\w/g, '');
+ //cleanContent = convertLinks(cleanContent);
const newComentAdded = (commentData) => {
let newPostObj = { ...post };
newPostObj.comments.push(commentData);
@@ -54,23 +55,25 @@ let Post = (props) => {
return (
- {!post.nonOrganicType ?
-
-
-
- {toProfileText}
-
- {" " + Moment(post.createdAt).fromNow()}
+
+ {!post.nonOrganicType ?
+
+
+
+ {toProfileText}
+
+ {" " + Moment(post.createdAt).fromNow()}
+
-
- {cleanContent}
-
- :
-
- News
- {cleanContent}
-
- }
+ {cleanContent}
+
+ :
+
+ News
+ {cleanContent}
+
+ }
+