aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/ProfileBody.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-04-09 19:22:30 -0400
committerIvan Chen <ivan@tagg.id>2021-04-09 19:23:23 -0400
commitad9db5ffd0b2fb6334fd8237e0600a76d25c7053 (patch)
tree7d7c58cbdb67e3e0945a6ed2ccaa658f0048e887 /src/components/profile/ProfileBody.tsx
parent2a9b090ad62c2d157e06c978ba4cbc663f7c550f (diff)
added navigation to profile
Diffstat (limited to 'src/components/profile/ProfileBody.tsx')
-rw-r--r--src/components/profile/ProfileBody.tsx16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/components/profile/ProfileBody.tsx b/src/components/profile/ProfileBody.tsx
index 00532507..527036f6 100644
--- a/src/components/profile/ProfileBody.tsx
+++ b/src/components/profile/ProfileBody.tsx
@@ -22,6 +22,7 @@ import {RootState} from '../../store/rootReducer';
import {ScreenType} from '../../types';
import {
connectChatAccount,
+ createChannel,
getUserAsProfilePreviewType,
SCREEN_HEIGHT,
SCREEN_WIDTH,
@@ -30,6 +31,8 @@ import {FriendsButton, BasicButton} from '../common';
import ToggleButton from './ToggleButton';
import {ChatContext} from '../../App';
import {useNavigation} from '@react-navigation/core';
+import {ChatListScreen} from '../../screens';
+import {ERROR_UNABLE_CONNECT_CHAT} from '../../constants/strings';
interface ProfileBodyProps {
onLayout: (event: LayoutChangeEvent) => void;
@@ -97,19 +100,12 @@ const ProfileBody: React.FC<ProfileBodyProps> = ({
};
const onPressMessage = async () => {
- let connected: boolean = await connectChatAccount(
- loggedInUserId,
- chatClient,
- );
- if (connected) {
- const channel = chatClient.channel('messaging', {
- members: [loggedInUserId, String(userXId)],
- });
- channel.create();
+ if (chatClient.user && userXId) {
+ const channel = await createChannel(loggedInUserId, userXId, chatClient);
setChannel(channel);
navigation.navigate('Chat');
} else {
- Alert.alert('Something wrong with chat');
+ Alert.alert(ERROR_UNABLE_CONNECT_CHAT);
}
};