-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathApp.js
101 lines (76 loc) · 2.11 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
import React from 'react';
import { Provider } from 'react-redux';
import { AppLoading ,
Constants ,
FacebookAds } from 'expo';
import Sentry from 'sentry-expo';
import { Ionicons } from '@expo/vector-icons';
import Main from './screens/main';
import currency from './actions/currency';
import language from './actions/language';
import theme from './actions/theme';
import portfolio from './actions/portfolio';
import application from './configuration/application';
import database from './configuration/database';
import configuration from './configuration/store';
import analytics from './utilities/analytics';
import cache from './utilities/cache';
Sentry.config ( application.sentry ).install ();
const store = configuration ();
export default class Application extends React.Component {
state = {
cache : false
};
async setCache () {
try {
await cache.assets ({
images : [] ,
fonts : [
Ionicons.font ,
{
'space-mono' : require ( './assets/fonts/SpaceMono-Regular.ttf' )
}
]
});
}
catch ( error ) {
console.log ( error.message );
}
finally {
this.setState ({
cache : true
});
}
}
componentWillMount () {
this.setCache ();
// Setup the local databases
database.portfolio.setup ();
database.settings.setup ();
// Setup the analytics
analytics.setup ();
// Get any data from the local databases
store.dispatch ( theme.get ());
store.dispatch ( language.get ());
store.dispatch ( portfolio.get ());
// Getting a users preferred currency is the catalyst to kicking off the correct calls to the currencies.
// Once we know this we know what currency conversion to use
store.dispatch ( currency.get ());
// Send test ads to the device if in development mode
if ( __DEV__ ) {
FacebookAds.AdSettings.addTestDevice ( FacebookAds.AdSettings.currentDeviceHash );
}
}
render () {
if ( this.state.cache ) {
return (
<Provider store = { store }>
<Main />
</Provider>
);
}
else {
return <AppLoading />;
}
}
};