Open comments on singlepost view
This commit is contained in:
@@ -13,18 +13,20 @@ import GlobalState from '../contexts/GlobalState.js';
|
||||
import i18n from "../i18nMessages.js";
|
||||
import ProfilePhotoCircle from './ProfilePhotoCircle.js';
|
||||
import { posthog } from './../PostHog.js';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
|
||||
|
||||
let Post = (props) => {
|
||||
const gState = useSnapshot(GlobalState);
|
||||
const viewer = gState.me;
|
||||
let [showCommentsB, changeshowCommentsB] = useState(false);
|
||||
let [showCommentsB, changeshowCommentsB] = useState(props.showComments || false);
|
||||
let [post, changePost] = useState(props.post);
|
||||
let [likes, changeLikes] = useState(Object.keys(post.reactions).length);
|
||||
let [bookmarked, changeBookmarked] = useState(post.bookmarks && post.bookmarks.includes(viewer._id));
|
||||
let toProfileText = post.toProfile && post.toProfile !== post.profileid ?
|
||||
<ProfilePhotoCircle profileid={post.toProfile} small={true} /> : undefined;
|
||||
let cleanContent = post.content.replace(/@[A-z]+:.+\w/g, '').trim();
|
||||
const navigation = useNavigation();
|
||||
//cleanContent = convertLinks(cleanContent);
|
||||
const newComentAdded = (commentData) => {
|
||||
let newPostObj = { ...post };
|
||||
@@ -105,7 +107,13 @@ let Post = (props) => {
|
||||
{likes}
|
||||
</Button>
|
||||
<Button icon="forum" labelStyle={{ fontSize: 17 }} style={{ flow: 1 }}
|
||||
onPress={() => { changeshowCommentsB(!showCommentsB) }}
|
||||
onPress={() => {
|
||||
// changeshowCommentsB(!showCommentsB) // Show comments
|
||||
// Change view to single post
|
||||
navigation.navigate("SinglePost", {
|
||||
postid: post._id,
|
||||
});
|
||||
}}
|
||||
color="#555"
|
||||
>
|
||||
{post.comments.length}
|
||||
@@ -133,12 +141,11 @@ let Post = (props) => {
|
||||
{showCommentsB && <NewComment postid={post._id} newComentAdded={newComentAdded} />}
|
||||
{
|
||||
showCommentsB &&
|
||||
<ScrollView style={{ maxHeight: 300 }}>
|
||||
<FlatList
|
||||
data={post.comments}
|
||||
renderItem={renderComment}
|
||||
keyExtractor={item => item.createdAt}
|
||||
/></ScrollView>
|
||||
/>
|
||||
}
|
||||
</Card>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user