aboutsummaryrefslogtreecommitdiff
path: root/src/routes/Routes.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-04-09 19:55:26 -0400
committerIvan Chen <ivan@tagg.id>2021-04-09 19:55:26 -0400
commit0a480048b41a80e8569ce57064d1b9716c3d25e3 (patch)
tree4f1118560c10dcdfa32e99d2b73c3d7814d7904d /src/routes/Routes.tsx
parent17de7d8312b10f84af2178f769ff92bf96ab47f5 (diff)
parent9d5ad9bea36c0b2abffd04b25126d18158017137 (diff)
Merge branch 'master' into tma784-style-message-input
# Conflicts: # src/screens/chat/ChatListScreen.tsx # src/screens/chat/ChatScreen.tsx
Diffstat (limited to 'src/routes/Routes.tsx')
-rw-r--r--src/routes/Routes.tsx15
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())) {