-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
106 lines (92 loc) · 3.14 KB
/
App.js
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* globals __DEV__ */
import React, { Component } from 'react';
import { StatusBar, View } from 'react-native';
import { AppLoading } from 'expo';
import * as Font from 'expo-font';
import Constants from 'expo-constants';
// eslint-disable-next-line import/no-extraneous-dependencies
import { FontAwesome, Entypo, Feather } from '@expo/vector-icons';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import Sentry from 'sentry-expo';
import thunk from 'redux-thunk';
import NavigationService from './utils/NavigationService';
import Onboarding from './containers/Onboarding';
import Navigation from './nav';
import reducer from './reducers';
import createDatabases from './apis/migrations';
import { initialize } from './apis';
import { restore } from './actions/authentication';
import { setup } from './actions/connectivity';
import I18n from './assets/i18n/i18n';
import * as overviewActions from './actions/overview';
import * as positionActions from './actions/position';
import { restoreLocalLocations } from './actions/locations';
import { restoreOnboardingStatus } from './actions/onboarding';
import * as settingsActions from './actions/settings';
Sentry.config('https://[email protected]/1193850').install();
initialize();
const store = createStore(reducer, applyMiddleware(thunk));
store.dispatch(setup());
// https://github.com/firebase/firebase-js-sdk/issues/97
// eslint-disable-next-line no-console
console.ignoredYellowBox = console.ignoredYellowBox || [];
// eslint-disable-next-line no-console
console.ignoredYellowBox = console.ignoredYellowBox.concat('Setting a timer for a long period');
class App extends Component {
state = {
isReady: false,
};
componentDidMount() {
Promise.all([
...this.loadFontsAsync(),
createDatabases(),
store.dispatch(positionActions.initialize()),
store.dispatch(
settingsActions.load({
enableInvitations: Constants.manifest.extra.enableInvitations,
})
),
]).then(() => {
I18n.setDateLocale();
this.setState({ isReady: true });
return Promise.all([
store.dispatch(restore()).then((restored) => {
if (!restored) {
return Promise.resolve();
}
return store.dispatch(overviewActions.initialize());
}),
store.dispatch(restoreLocalLocations()),
store.dispatch(restoreOnboardingStatus()),
]);
});
}
componentDidCatch(error, errorInfo) {
Sentry.captureException(error, { extra: errorInfo });
throw error;
}
loadFontsAsync() {
const fonts = [FontAwesome.font, Entypo.font, Feather.font];
return fonts.map(Font.loadAsync);
}
render() {
if (!this.state.isReady) {
return <AppLoading />;
}
return (
<Provider store={store}>
<View style={{ flex: 1 }}>
<StatusBar barStyle="dark-content" />
<Navigation
ref={(navigatorRef) => {
NavigationService.setTopLevelNavigator(navigatorRef);
}}
/>
{__DEV__ && <Onboarding />}
</View>
</Provider>
);
}
}
export default App;