diff options
Diffstat (limited to 'src/screens')
| -rw-r--r-- | src/screens/chat/ChatListScreen.tsx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/screens/chat/ChatListScreen.tsx b/src/screens/chat/ChatListScreen.tsx index eb886232..f2395f0a 100644 --- a/src/screens/chat/ChatListScreen.tsx +++ b/src/screens/chat/ChatListScreen.tsx @@ -3,6 +3,7 @@ import {StackNavigationProp} from '@react-navigation/stack'; import React, {useContext, useEffect, useMemo, useState} from 'react'; import {Alert, SafeAreaView, StatusBar, StyleSheet, View} from 'react-native'; import {useSelector, useStore} from 'react-redux'; +import {connectChatAccount} from '../../utils'; import {ChannelList, Chat} from 'stream-chat-react-native'; import {ChatContext} from '../../App'; import {TabsGradient} from '../../components'; @@ -43,10 +44,20 @@ const ChatListScreen: React.FC<ChatListScreenProps> = () => { ); useEffect(() => { - if (!chatClientReady) { - Alert.alert('Something wrong with chat'); + let connected: boolean = !chatClient.user; + if (!connected) { + connectChatAccount(loggedInUserId, chatClient) + .then((success) => { + if (!success) { + Alert.alert('Something wrong with chat'); + } + }) + .catch((err) => { + console.log('Error connecting to chat: ', err); + Alert.alert('Something wrong with chat'); + }); } - }, [chatClientReady]); + }, []); return ( <View style={styles.background}> |
