diff options
| author | Shravya Ramesh <shravs1208@gmail.com> | 2021-04-09 15:19:49 -0700 |
|---|---|---|
| committer | Shravya Ramesh <shravs1208@gmail.com> | 2021-04-09 15:19:49 -0700 |
| commit | 6527289eb6249cfd057c47d0f797133ab8052339 (patch) | |
| tree | d2e5bdfaabf57042b8990fb03f1676376c3babe0 /src/screens | |
| parent | 444dc434b63c7a24d3447e23eb9b4a9b469566a7 (diff) | |
major issue fixed
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}> |
