aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/ProfileBody.tsx
diff options
context:
space:
mode:
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 (