import {useNavigation} from '@react-navigation/native'; import React, { createRef, LegacyRef, MutableRefObject, useContext, useEffect, useRef, useState, } from 'react'; import { Image, KeyboardAvoidingView, Platform, StatusBar, StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View, } from 'react-native'; import Animated, {EasingNode} from 'react-native-reanimated'; import Video from 'react-native-video'; import {useDispatch, useSelector, useStore} from 'react-redux'; import {headerBarOptions} from '../../routes'; import {MomentContext} from '../../screens/profile/IndividualMoment'; import {deleteMomentTag, loadMomentTags} from '../../services'; import {loadUserMoments} from '../../store/actions'; import {RootState} from '../../store/rootReducer'; import {MomentPostType, MomentTagType, ScreenType, UserType} from '../../types'; import { getTimePosted, HeaderHeight, isIPhoneX, navigateToProfile, normalize, SCREEN_HEIGHT, SCREEN_WIDTH, } from '../../utils'; import {mentionPartTypes, renderTextWithMentions} from '../../utils/comments'; import {AddComment} from '../comments'; import CommentsCount from '../comments/CommentsCount'; import {MomentTags} from '../common'; import {MomentMoreInfoDrawer, TaggAvatar} from '../profile'; import IndividualMomentTitleBar from './IndividualMomentTitleBar'; interface MomentPostProps { moment: MomentPostType; userXId: string | undefined; screenType: ScreenType; } const MomentPost: React.FC = ({ moment, userXId, screenType, }) => { const navigation = useNavigation(); const dispatch = useDispatch(); const {userId: loggedInUserId, username: loggedInUsername} = useSelector( (state: RootState) => state.user.user, ); const {user} = useSelector((state: RootState) => userXId ? state.userX[screenType][userXId] : state.user, ); const state: RootState = useStore().getState(); const isOwnProfile = user.username === loggedInUsername; const [tags, setTags] = useState([]); const [visible, setVisible] = useState(false); const [drawerVisible, setDrawerVisible] = useState(false); const [hideText, setHideText] = useState(false); const [fadeValue, setFadeValue] = useState>( new Animated.Value(0), ); const [commentCount, setCommentCount] = useState( moment.comments_count, ); const [aspectRatio, setAspectRatio] = useState(1); const [momentTagId, setMomentTagId] = useState(''); const imageRef = useRef(null); const videoRef = useRef