aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/ProfileBody.tsx
diff options
context:
space:
mode:
authorShravya Ramesh <shravs1208@gmail.com>2021-04-09 14:40:03 -0700
committerShravya Ramesh <shravs1208@gmail.com>2021-04-09 14:40:03 -0700
commit3d26676ea1e818b585b4b224f643524994a0e893 (patch)
treee21265fe5a24007cac2269fc7c2c08c8e780ed4f /src/components/profile/ProfileBody.tsx
parentfbfb36b381216e0b50324064c79b0c0f5efc6a6c (diff)
Connecting during login, app entry, msg btn tap
Diffstat (limited to 'src/components/profile/ProfileBody.tsx')
-rw-r--r--src/components/profile/ProfileBody.tsx23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/components/profile/ProfileBody.tsx b/src/components/profile/ProfileBody.tsx
index e23249fa..eebdb167 100644
--- a/src/components/profile/ProfileBody.tsx
+++ b/src/components/profile/ProfileBody.tsx
@@ -21,6 +21,7 @@ import {NO_PROFILE} from '../../store/initialStates';
import {RootState} from '../../store/rootReducer';
import {ScreenType} from '../../types';
import {
+ connectChatAccount,
getUserAsProfilePreviewType,
SCREEN_HEIGHT,
SCREEN_WIDTH,
@@ -96,16 +97,20 @@ const ProfileBody: React.FC<ProfileBodyProps> = ({
};
const onPressMessage = async () => {
- if (!chatClient.user) {
- // TODO: Add refresh control to retry establishing chat connection
- Alert.alert('Unable to connect chat');
+ let connected: boolean = !chatClient.user;
+ if (!connected) {
+ connected = await connectChatAccount(loggedInUserId, chatClient);
+ if (!connected) {
+ Alert.alert('Unable to connect chat');
+ }
+ } else {
+ const channel = chatClient.channel('messaging', {
+ members: [loggedInUserId, String(userXId)],
+ });
+ channel.create();
+ setChannel(channel);
+ navigation.navigate('Chat');
}
- const channel = chatClient.channel('messaging', {
- members: [loggedInUserId, String(userXId)],
- });
- channel.create();
- setChannel(channel);
- navigation.navigate('Chat');
};
return (