diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/profile/ProfileBody.tsx | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/components/profile/ProfileBody.tsx b/src/components/profile/ProfileBody.tsx index 9b19b866..1a8d1e1a 100644 --- a/src/components/profile/ProfileBody.tsx +++ b/src/components/profile/ProfileBody.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useContext} from 'react'; import {LayoutChangeEvent, Linking, StyleSheet, Text, View} from 'react-native'; import {normalize} from 'react-native-elements'; import {useDispatch, useSelector, useStore} from 'react-redux'; @@ -20,6 +20,9 @@ import { } from '../../utils'; import {FriendsButton, BasicButton} from '../common'; import ToggleButton from './ToggleButton'; +// import {ChatContext} from '../../App'; +// import {useNavigation} from '@react-navigation/core'; +// import AsyncStorage from '@react-native-community/async-storage'; interface ProfileBodyProps { onLayout: (event: LayoutChangeEvent) => void; @@ -53,6 +56,9 @@ const ProfileBody: React.FC<ProfileBodyProps> = ({ const state: RootState = useStore().getState(); const dispatch = useDispatch(); + // const navigation = useNavigation(); + // const {chatClient, setChannel} = useContext(ChatContext); + const loggedInUserId = state.user.user.userId; const handleAcceptRequest = async () => { await dispatch(acceptFriendRequest({id, username, first_name, last_name})); @@ -69,7 +75,10 @@ const ProfileBody: React.FC<ProfileBodyProps> = ({ if ( userXId && !isBlocked && - (friendship_status === 'no_record' || friendship_status === 'friends') && + (friendship_status === 'no_record' || + friendship_status === 'friends' || + (friendship_status === 'requested' && + friendship_requester_id === loggedInUserId)) && canViewProfile(state, userXId, screenType) ) { return true; @@ -78,9 +87,23 @@ const ProfileBody: React.FC<ProfileBodyProps> = ({ } }; - const onPressMessage = () => { - // TODO: Add navigation to ChatScreen - console.log('Navigate to the individual chat screen'); + const onPressMessage = async () => { + // TODO: Use function from util to create the channel and then navigate to screen + // const channelName = username + ' and ' + state.user.user.username; + // const chatToken = await AsyncStorage.getItem('chatToken'); + // await chatClient.connectUser( + // { + // id: loggedInUserId, + // }, + // chatToken, + // ); + // const channel = chatClient.channel('messaging', { + // name: channelName, + // members: [loggedInUserId, String(userXId)], + // }); + // channel.create(); + // navigation.navigate('Chat'); + console.log('Navigate to ChatScreen'); }; return ( |