-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathindex.js
More file actions
92 lines (75 loc) · 2.82 KB
/
index.js
File metadata and controls
92 lines (75 loc) · 2.82 KB
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
85
86
87
88
89
90
91
92
import React from 'react';
import { Platform } from 'react-native';
import { registerRootComponent } from 'expo';
import crashlytics from '@react-native-firebase/crashlytics';
import { loadErrorMessages, loadDevMessages } from "@apollo/client/dev";
import AsyncStorage from '@react-native-async-storage/async-storage';
import { persistCache } from 'apollo-cache-persist';
import { getApps, initializeApp } from '@react-native-firebase/app';
import database from '@react-native-firebase/database';
import * as SplashScreen from 'expo-splash-screen';
import 'react-native-gesture-handler';
import 'react-native-console-time-polyfill';
import 'reflect-metadata';
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
// Keep the splash screen visible while we fetch resources
SplashScreen.preventAutoHideAsync();
import { store, persistor } from './src/application/store';
import createApolloClient from './src/data/apollo/createApolloClient';
import AppNavigator from './src/navigation/AppNavigator';
if (__DEV__) {
// Adds messages only in a dev environment
loadDevMessages();
loadErrorMessages();
}
// Enable Crashlytics collection (enabled by default, but explicitly set for clarity)
crashlytics().setCrashlyticsCollectionEnabled(true);
// Initialize Firebase if not already initialized
console.log('Firebase apps before init:', getApps().length);
if (!getApps().length) {
console.log('Calling initializeApp()');
initializeApp({
apiKey: 'AIzaSyDb3uTSlVozaog4jNJB3_1wlESBF80sCX0',
appId: '1:375702423113:ios:ddc3bfe55bd62d38eda198',
messagingSenderId: '375702423113',
projectId: 'arkhamblob',
storageBucket: 'arkhamblob.appspot.com',
databaseURL: 'https://arkhamblob.firebaseio.com',
});
console.log('initializeApp() completed');
}
console.log('Firebase apps after init:', getApps().length);
// database().setPersistenceEnabled(true);
const [apolloClient, anonClient] = createApolloClient(store);
persistCache({
cache: apolloClient.cache,
storage: AsyncStorage,
});
function App() {
const [appIsReady, setAppIsReady] = React.useState(false);
React.useEffect(() => {
async function prepare() {
try {
// Enable edge-to-edge on Android
// You can add any additional loading logic here
// For now, we'll just mark it as ready
await new Promise(resolve => setTimeout(resolve, 100)); // Small delay to ensure everything is initialized
} catch (e) {
console.warn(e);
} finally {
setAppIsReady(true);
await SplashScreen.hideAsync();
}
}
prepare();
}, []);
if (!appIsReady) {
return null;
}
const storeProps = { redux: store, persistor: persistor, apollo: apolloClient, anonApollo: anonClient };
return (
<AppNavigator store={storeProps} />
);
}
database().setPersistenceEnabled(true);
registerRootComponent(App);