diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-04-09 19:49:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-09 19:49:27 -0400 |
| commit | 9d5ad9bea36c0b2abffd04b25126d18158017137 (patch) | |
| tree | 7d7c58cbdb67e3e0945a6ed2ccaa658f0048e887 /src/routes/Routes.tsx | |
| parent | a6580f418e87775a5e683e56735952df4f7fa5a9 (diff) | |
| parent | ad9db5ffd0b2fb6334fd8237e0600a76d25c7053 (diff) | |
Merge pull request #356 from shravyaramesh/tma767-message-button
[TMA767] Message button
Diffstat (limited to 'src/routes/Routes.tsx')
| -rw-r--r-- | src/routes/Routes.tsx | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index 819ca785..5ce0c771 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -1,15 +1,17 @@ +import AsyncStorage from '@react-native-community/async-storage'; import messaging from '@react-native-firebase/messaging'; -import React, {useEffect, useState} from 'react'; +import React, {useContext, useEffect, useState} from 'react'; import DeviceInfo from 'react-native-device-info'; import SplashScreen from 'react-native-splash-screen'; -import {useDispatch, useSelector} from 'react-redux'; +import {useDispatch, useSelector, useStore} from 'react-redux'; +import {ChatContext} from '../App'; import {fcmService, getCurrentLiveVersions} from '../services'; import { updateNewNotificationReceived, updateNewVersionAvailable, } from '../store/actions'; import {RootState} from '../store/rootReducer'; -import {userLogin} from '../utils'; +import {userLogin, connectChatAccount} from '../utils'; import Onboarding from './onboarding'; import NavigationBar from './tabs'; @@ -17,6 +19,9 @@ const Routes: React.FC = () => { const { user: {userId}, } = useSelector((state: RootState) => state.user); + const state: RootState = useStore().getState(); + const loggedInUserId = state.user.user.userId; + const {chatClient} = useContext(ChatContext); const [newVersionAvailable, setNewVersionAvailable] = useState(false); const dispatch = useDispatch(); @@ -53,6 +58,10 @@ const Routes: React.FC = () => { }, []); useEffect(() => { + connectChatAccount(loggedInUserId, chatClient); + }, [loggedInUserId]); + + useEffect(() => { const checkVersion = async () => { const liveVersions = await getCurrentLiveVersions(); if (liveVersions && !liveVersions.includes(DeviceInfo.getVersion())) { |
