diff --git a/App.js b/App.js
index 5a060ef..3991853 100644
--- a/App.js
+++ b/App.js
@@ -23,6 +23,7 @@ import MenuView from './Views/Menu.js';
import ProfileSettings from './Views/ProfileSettings.js';
import InviteView from './Views/Invite.js';
import MediaView from './components/MediaView.js';
+import { useSnapshot } from 'valtio';
import GlobalState from './contexts/GlobalState.js';
@@ -83,6 +84,8 @@ async function registerForPushNotificationsAsync() {
const MainNavigation = () => {
+ const gState = useSnapshot(GlobalState);
+ const viewer = gState.me;
const [expoPushToken, setExpoPushToken] = useState('');
const [notification, setNotification] = useState(false);
const notificationListener = useRef();
@@ -109,10 +112,15 @@ const MainNavigation = () => {
});
const interval = setInterval(async () => {
- if(await API.isLoggedIn())
- console.log("Updating me")
- GlobalState.me = await API.getMe();
- }, 10000);
+ if(await API.isLoggedIn()){
+ let me = await API.getMe();
+ //console.log(JSON.stringify(viewer), JSON.stringify(me))
+ if(JSON.stringify(viewer) !== JSON.stringify(me)){
+ console.log("Updating me")
+ GlobalState.me = me;
+ }
+ }
+ }, 30000);
return () => {
Notifications.removeNotificationSubscription(notificationListener.current);
diff --git a/Views/NewPost.js b/Views/NewPost.js
index a0f6667..175e25f 100644
--- a/Views/NewPost.js
+++ b/Views/NewPost.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useEffect, useState } from 'react';
import { View, TextInput, Image } from "react-native";
import { Text, Button, Divider } from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";
@@ -9,11 +9,28 @@ import i18n from "../i18nMessages";
import Media from '../components/Media';
-let NewPostView = ({ writeTo }) => {
+let NewPostView = (props) => {
let [postContent, setPostContent] = useState('');
let [extraContent, setExtraContent] = useState([]);
+ let [toProfile, setToProfile] = useState([]);
const [photo, setPhoto] = React.useState(null);
const navigation = useNavigation();
+
+ useEffect(() => {
+ let subscribed = true;
+ const getProfileData = async () => {
+ if (!props.route.params?.toProfile) return 0;
+ await API.getUserProfile(props.route.params.toProfile).then((profileObj) => {
+ if (!subscribed) return 0;
+ setToProfile(profileObj);
+ });
+ };
+ getProfileData();
+ return () => {
+ subscribed = false;
+ }
+ }, []);
+
const pickImage = async () => {
// No permissions request is necessary for launching the image library
let result = await ImagePicker.launchImageLibraryAsync({
@@ -27,8 +44,8 @@ let NewPostView = ({ writeTo }) => {
setPhoto(result);
let newPhotoURLs = await handleUploadPhoto(result);
let newExtraContent = [extraContent]
- newPhotoURLs.forEach((newPhotoURL)=>{
- newExtraContent = ["@image:" + newPhotoURL].concat(newExtraContent);
+ newPhotoURLs.forEach((newPhotoURL) => {
+ newExtraContent = ["@image:" + newPhotoURL].concat(newExtraContent);
});
setExtraContent(newExtraContent);
setPhoto(null);
@@ -64,7 +81,7 @@ let NewPostView = ({ writeTo }) => {
return data.fileName;
})
.catch((err) => console.error(err)));
-
+
} catch (err) {
console.log(err);
alert("Something went wrong");
@@ -76,7 +93,7 @@ let NewPostView = ({ writeTo }) => {
const handleNewPostButton = async () => {
//setPostContent('');
- API.newPost(postContent + " " + extraContent.join(" ")).then((newPost) => {
+ API.newPost(postContent + " " + extraContent.join(" "), props.route.params.toProfile).then((newPost) => {
setPostContent('');
setExtraContent([]);
navigation.goBack();
@@ -93,6 +110,12 @@ let NewPostView = ({ writeTo }) => {
{i18n.t("message.post")}
+ {
+ toProfile._id ?
+
+ Posting on: {toProfile._id ? toProfile.profile.firstName + " " + toProfile.profile.lastName : ''}
+ : <>>
+ }
{
backgroundColor: "#c44d56",
justifyContent: 'center',
alignItems: 'center',
+ elevation: 10,
+ zIndex: 1,
}}>
{
- setShowNewPost(!showNewPost);
+ //setShowNewPost(!showNewPost);
+ navigation.navigate('NewPost', {toProfile: profile._id})
}} />
-
{ showNewPost ?
setPosts([newPost, ...Posts])} />
diff --git a/app.json b/app.json
index 931e40a..83d44a1 100644
--- a/app.json
+++ b/app.json
@@ -2,7 +2,7 @@
"expo": {
"name": "EMI Social",
"slug": "emi-social",
- "version": "1.2.0",
+ "version": "1.2.1",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
@@ -27,7 +27,7 @@
},
"package": "com.emi.social",
"googleServicesFile": "./google-services.json",
- "versionCode": 2
+ "versionCode": 3
},
"web": {
"favicon": "./assets/favicon.png"
diff --git a/components/ProfileHeader.js b/components/ProfileHeader.js
index d901274..64c5c91 100644
--- a/components/ProfileHeader.js
+++ b/components/ProfileHeader.js
@@ -11,15 +11,17 @@ const ProfileHeader = ({ profileObj }) => {
return (
<>
-
-
+
+
{profileObj.profile.description}