diff options
Diffstat (limited to 'src/components/profile/ProfileBody.tsx')
-rw-r--r-- | src/components/profile/ProfileBody.tsx | 16 |
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); } }; |