forked from benawad/dogehouse
-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.tsx
84 lines (75 loc) · 2.66 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import { LinkingOptions, NavigationContainer } from "@react-navigation/native";
import React, { useEffect } from "react";
import { LogBox, StatusBar } from "react-native";
import "react-native-gesture-handler";
import "react-native-get-random-values";
import { SafeAreaProvider } from "react-native-safe-area-context";
import SplashScreen from "react-native-splash-screen";
import Toast from "react-native-toast-message";
import { registerGlobals } from "react-native-webrtc";
import { QueryClientProvider } from "react-query";
import { colors } from "./src/constants/dogeStyle";
import { queryClient } from "./src/lib/queryClient";
import { useTokenStore } from "./src/modules/auth/useTokenStore";
import { useSoundEffectStore } from "./src/modules/sound-effect/useSoundEffectStore";
import { useVoiceStore } from "./src/modules/webrtc/stores/useVoiceStore";
import { WebSocketProvider } from "./src/modules/ws/WebSocketProvider";
import { AuthenticationSwitch } from "./src/navigation/AuthenticationSwitch";
import { navigationRef } from "./src/navigation/RootNavigation";
import { MainWsHandlerProvider } from "./src/shared-hooks/useMainWsHandler";
LogBox.ignoreLogs(["Setting a timer"]);
const App: React.FC = () => {
registerGlobals();
const loadTokens = useTokenStore((state) => state.loadTokens);
useSoundEffectStore();
const isTokenStoreReady = useTokenStore(
(s) => s.accessToken !== undefined && s.refreshToken !== undefined
);
if (!isTokenStoreReady) {
loadTokens();
}
useEffect(() => {
if (isTokenStoreReady) {
SplashScreen.hide();
}
}, [isTokenStoreReady]);
const isVoicePrepared = useVoiceStore((s) => s.device !== undefined);
const prepare = useVoiceStore((state) => state.prepare);
if (!isVoicePrepared) {
prepare();
}
const deepLinksConf = {
screens: {
Room: "room/:roomId",
},
};
const linking: LinkingOptions = {
prefixes: ["dogehouse://", "https://next.dogehouse.tv"],
config: deepLinksConf,
};
return (
<WebSocketProvider shouldConnect={true}>
<QueryClientProvider client={queryClient}>
<MainWsHandlerProvider />
<SafeAreaProvider>
<NavigationContainer ref={navigationRef} linking={linking}>
<StatusBar
barStyle="light-content"
backgroundColor={colors.primary900}
/>
<AuthenticationSwitch />
<Toast ref={(ref) => Toast.setRef(ref)} />
</NavigationContainer>
</SafeAreaProvider>
</QueryClientProvider>
</WebSocketProvider>
);
};
export default App;