Fix newpost and ready for new version
This commit is contained in:
14
App.js
14
App.js
@@ -23,6 +23,7 @@ import MenuView from './Views/Menu.js';
|
|||||||
import ProfileSettings from './Views/ProfileSettings.js';
|
import ProfileSettings from './Views/ProfileSettings.js';
|
||||||
import InviteView from './Views/Invite.js';
|
import InviteView from './Views/Invite.js';
|
||||||
import MediaView from './components/MediaView.js';
|
import MediaView from './components/MediaView.js';
|
||||||
|
import { useSnapshot } from 'valtio';
|
||||||
import GlobalState from './contexts/GlobalState.js';
|
import GlobalState from './contexts/GlobalState.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -83,6 +84,8 @@ async function registerForPushNotificationsAsync() {
|
|||||||
|
|
||||||
|
|
||||||
const MainNavigation = () => {
|
const MainNavigation = () => {
|
||||||
|
const gState = useSnapshot(GlobalState);
|
||||||
|
const viewer = gState.me;
|
||||||
const [expoPushToken, setExpoPushToken] = useState('');
|
const [expoPushToken, setExpoPushToken] = useState('');
|
||||||
const [notification, setNotification] = useState(false);
|
const [notification, setNotification] = useState(false);
|
||||||
const notificationListener = useRef();
|
const notificationListener = useRef();
|
||||||
@@ -109,10 +112,15 @@ const MainNavigation = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const interval = setInterval(async () => {
|
const interval = setInterval(async () => {
|
||||||
if(await API.isLoggedIn())
|
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")
|
console.log("Updating me")
|
||||||
GlobalState.me = await API.getMe();
|
GlobalState.me = me;
|
||||||
}, 10000);
|
}
|
||||||
|
}
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
Notifications.removeNotificationSubscription(notificationListener.current);
|
Notifications.removeNotificationSubscription(notificationListener.current);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { View, TextInput, Image } from "react-native";
|
import { View, TextInput, Image } from "react-native";
|
||||||
import { Text, Button, Divider } from "react-native-paper";
|
import { Text, Button, Divider } from "react-native-paper";
|
||||||
import { SafeAreaView } from "react-native-safe-area-context";
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
@@ -9,11 +9,28 @@ import i18n from "../i18nMessages";
|
|||||||
import Media from '../components/Media';
|
import Media from '../components/Media';
|
||||||
|
|
||||||
|
|
||||||
let NewPostView = ({ writeTo }) => {
|
let NewPostView = (props) => {
|
||||||
let [postContent, setPostContent] = useState('');
|
let [postContent, setPostContent] = useState('');
|
||||||
let [extraContent, setExtraContent] = useState([]);
|
let [extraContent, setExtraContent] = useState([]);
|
||||||
|
let [toProfile, setToProfile] = useState([]);
|
||||||
const [photo, setPhoto] = React.useState(null);
|
const [photo, setPhoto] = React.useState(null);
|
||||||
const navigation = useNavigation();
|
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 () => {
|
const pickImage = async () => {
|
||||||
// No permissions request is necessary for launching the image library
|
// No permissions request is necessary for launching the image library
|
||||||
let result = await ImagePicker.launchImageLibraryAsync({
|
let result = await ImagePicker.launchImageLibraryAsync({
|
||||||
@@ -27,7 +44,7 @@ let NewPostView = ({ writeTo }) => {
|
|||||||
setPhoto(result);
|
setPhoto(result);
|
||||||
let newPhotoURLs = await handleUploadPhoto(result);
|
let newPhotoURLs = await handleUploadPhoto(result);
|
||||||
let newExtraContent = [extraContent]
|
let newExtraContent = [extraContent]
|
||||||
newPhotoURLs.forEach((newPhotoURL)=>{
|
newPhotoURLs.forEach((newPhotoURL) => {
|
||||||
newExtraContent = ["@image:" + newPhotoURL].concat(newExtraContent);
|
newExtraContent = ["@image:" + newPhotoURL].concat(newExtraContent);
|
||||||
});
|
});
|
||||||
setExtraContent(newExtraContent);
|
setExtraContent(newExtraContent);
|
||||||
@@ -76,7 +93,7 @@ let NewPostView = ({ writeTo }) => {
|
|||||||
|
|
||||||
const handleNewPostButton = async () => {
|
const handleNewPostButton = async () => {
|
||||||
//setPostContent('');
|
//setPostContent('');
|
||||||
API.newPost(postContent + " " + extraContent.join(" ")).then((newPost) => {
|
API.newPost(postContent + " " + extraContent.join(" "), props.route.params.toProfile).then((newPost) => {
|
||||||
setPostContent('');
|
setPostContent('');
|
||||||
setExtraContent([]);
|
setExtraContent([]);
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
@@ -93,6 +110,12 @@ let NewPostView = ({ writeTo }) => {
|
|||||||
{i18n.t("message.post")}
|
{i18n.t("message.post")}
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
|
{
|
||||||
|
toProfile._id ?
|
||||||
|
<Text style={{ paddingLeft: 10, paddingBottom: 5 }}>
|
||||||
|
Posting on: {toProfile._id ? toProfile.profile.firstName + " " + toProfile.profile.lastName : ''}
|
||||||
|
</Text> : <></>
|
||||||
|
}
|
||||||
<Divider bold={true} />
|
<Divider bold={true} />
|
||||||
<TextInput
|
<TextInput
|
||||||
value={postContent}
|
value={postContent}
|
||||||
|
|||||||
@@ -104,23 +104,26 @@ let Profile = ({ navigation, route }) => {
|
|||||||
backgroundColor: "#c44d56",
|
backgroundColor: "#c44d56",
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
elevation: 10,
|
||||||
|
zIndex: 1,
|
||||||
}}>
|
}}>
|
||||||
<IconButton icon={showNewPost ? 'remove' : "add"} mode="outlined" color="white" onPress={()=>{
|
<IconButton icon={showNewPost ? 'remove' : "add"} mode="outlined" color="white" onPress={()=>{
|
||||||
setShowNewPost(!showNewPost);
|
//setShowNewPost(!showNewPost);
|
||||||
|
navigation.navigate('NewPost', {toProfile: profile._id})
|
||||||
}} />
|
}} />
|
||||||
</View>
|
</View>
|
||||||
<Button title="Images" icon={tag == 'images' ? 'remove' : "image"} mode="outlined" onPress={()=>{
|
<Button style={{paddingLeft:12, backgroundColor:"#fff"}} title="Images" icon={tag == 'images' ? 'remove' : "image"} mode="outlined" onPress={()=>{
|
||||||
if(tag == 'images') return setTag('');
|
if(tag == 'images') return setTag('');
|
||||||
setTag('images');
|
setTag('images');
|
||||||
}}>Images</Button>
|
}}>{tag == 'images' ? "Images" : ''}</Button>
|
||||||
<Button title="Media" icon={tag == 'media' ? 'remove' : "subscriptions"} mode="outlined" onPress={()=>{
|
<Button style={{paddingLeft:12, backgroundColor:"#fff"}} title="Media" icon={tag == 'media' ? 'remove' : "subscriptions"} mode="outlined" onPress={()=>{
|
||||||
if(tag == 'media') return setTag('');
|
if(tag == 'media') return setTag('');
|
||||||
setTag('media');
|
setTag('media');
|
||||||
}}>Media</Button>
|
}}>{tag == 'media' ? "Media" : ''}</Button>
|
||||||
<Button title="Embedded" icon={tag == 'embedded' ? 'remove' : "folder"} mode="outlined" onPress={()=>{
|
<Button style={{paddingLeft:12, backgroundColor:"#fff"}} title="Embedded" icon={tag == 'embedded' ? 'remove' : "folder"} mode="outlined" onPress={()=>{
|
||||||
if(tag == 'embedded') return setTag('');
|
if(tag == 'embedded') return setTag('');
|
||||||
setTag('embedded');
|
setTag('embedded');
|
||||||
}}>Files</Button>
|
}}>{tag == 'embedded' ? "Files" : ''}</Button>
|
||||||
</View>
|
</View>
|
||||||
{ showNewPost ?
|
{ showNewPost ?
|
||||||
<NewPost newPostCB={(newPost) => setPosts([newPost, ...Posts])} />
|
<NewPost newPostCB={(newPost) => setPosts([newPost, ...Posts])} />
|
||||||
|
|||||||
4
app.json
4
app.json
@@ -2,7 +2,7 @@
|
|||||||
"expo": {
|
"expo": {
|
||||||
"name": "EMI Social",
|
"name": "EMI Social",
|
||||||
"slug": "emi-social",
|
"slug": "emi-social",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"orientation": "portrait",
|
"orientation": "portrait",
|
||||||
"icon": "./assets/icon.png",
|
"icon": "./assets/icon.png",
|
||||||
"splash": {
|
"splash": {
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
},
|
},
|
||||||
"package": "com.emi.social",
|
"package": "com.emi.social",
|
||||||
"googleServicesFile": "./google-services.json",
|
"googleServicesFile": "./google-services.json",
|
||||||
"versionCode": 2
|
"versionCode": 3
|
||||||
},
|
},
|
||||||
"web": {
|
"web": {
|
||||||
"favicon": "./assets/favicon.png"
|
"favicon": "./assets/favicon.png"
|
||||||
|
|||||||
@@ -11,15 +11,17 @@ const ProfileHeader = ({ profileObj }) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card elevation={3}>
|
<Card elevation={3}>
|
||||||
<Card.Cover source={{ uri: photoUrl, cache: 'force-cache' }} />
|
<Card.Cover source={{ uri: photoUrl, cache: 'force-cache' }} style={{
|
||||||
<Card.Content>
|
height: 300
|
||||||
|
}} />
|
||||||
|
<Card.Content style={{}}>
|
||||||
<Title style={{position: "absolute", top: -60, left: 10, backgroundColor: "rgba(255,255,255,0.4)", padding: 10}}>
|
<Title style={{position: "absolute", top: -60, left: 10, backgroundColor: "rgba(255,255,255,0.4)", padding: 10}}>
|
||||||
<UserName profileid={profileObj._id} />
|
<UserName profileid={profileObj._id} />
|
||||||
</Title>
|
</Title>
|
||||||
<Paragraph style={{paddingTop:10}}>{profileObj.profile.description}</Paragraph>
|
<Paragraph style={{paddingTop:10}}>{profileObj.profile.description}</Paragraph>
|
||||||
<View style={{
|
<View style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
top: -190,
|
top: -290,
|
||||||
right: 10,
|
right: 10,
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50,
|
height: 50,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//import { getLocales } from 'expo-localization';
|
import { getLocales } from 'expo-localization';
|
||||||
import { I18n } from 'i18n-js';
|
import { I18n } from 'i18n-js';
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import 'moment/min/locales'
|
import 'moment/min/locales'
|
||||||
@@ -150,7 +150,7 @@ const messages = {
|
|||||||
const i18n = new I18n(messages);
|
const i18n = new I18n(messages);
|
||||||
|
|
||||||
// Set the locale once at the beginning of your app.
|
// Set the locale once at the beginning of your app.
|
||||||
i18n.locale = 'es';//getLocales()[0].languageCode;
|
i18n.locale = getLocales()[0].languageCode;
|
||||||
moment.locale(i18n.locale);
|
moment.locale(i18n.locale);
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
Reference in New Issue
Block a user