aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShravya Ramesh <shravs1208@gmail.com>2021-04-08 13:18:56 -0700
committerShravya Ramesh <shravs1208@gmail.com>2021-04-08 13:18:56 -0700
commit96ce07324b8b6fae3ced4da14d96a5ec5ca4ad6d (patch)
treeccc44e5a1ac4c96bd8c2e285d44521286f35259e
parente70a8472259929cb28dadb40b57c593b68ab1983 (diff)
To test nav [wip after merging utils for chat]
-rw-r--r--src/components/profile/ProfileBody.tsx33
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 (