forked from BlueWallet/BlueWallet
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathApp.tsx
More file actions
104 lines (88 loc) · 2.83 KB
/
App.tsx
File metadata and controls
104 lines (88 loc) · 2.83 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
93
94
95
96
97
98
99
100
101
102
103
104
import * as Sentry from '@sentry/react-native';
import React, { Component } from 'react';
import { I18nextProvider } from 'react-i18next';
import { View, StyleSheet, LogBox } from 'react-native';
import codePush from 'react-native-code-push';
import Toast from 'react-native-toast-message';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { Navigator } from 'app/navigators';
import { AppStateManager } from 'app/services';
import NotificationsServices from 'app/services/NotificationServices';
import { AppSettingsAction } from 'app/state/appSettings/actions';
import { AuthenticationAction } from 'app/state/authentication/actions';
import { persistor, store } from 'app/state/store';
import { isIos } from 'app/styles/helpers';
import config from './src/config';
const i18n = require('./loc');
LogBox.ignoreAllLogs(process.env.LOG_BOX_IGNORE === 'true');
const sentryOptions = {
dsn: isIos() ? config.sentryDsnIOS : config.sentryDsnAndroid,
tracesSampleRate: 0.25,
debug: config.environment === 'dev',
environment: config.environment,
};
const getNewKey = () => new Date().toISOString();
const codePushOptions = {
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
installMode: codePush.InstallMode.IMMEDIATE,
minimumBackgroundDuration: 30 * 60, // 30 minutes
updateDialog: false,
deploymentKey: isIos() ? config.codepushDeploymentKeyIOS : config.codepushDeploymentKeyAndroid,
};
if (!__DEV__) {
Sentry.init(sentryOptions);
}
class CodePushClass extends Component<null, null> {
render() {
return null;
}
}
const WithCodePush = codePush(codePushOptions)(CodePushClass);
class App extends React.PureComponent {
state = {
unlockKey: getNewKey(),
};
lockScreen = () => {
store.dispatch({
type: AuthenticationAction.SetIsAuthenticated,
isAuthenticated: false,
});
};
setUnlockScreenKey = () => {
this.setState({
unlockKey: getNewKey(),
});
store.dispatch({
type: AppSettingsAction.ClearBadge,
});
};
render() {
return (
<>
{!__DEV__ && <WithCodePush />}
<I18nextProvider i18n={i18n}>
<Provider store={store}>
<AppStateManager
handleAppComesToForeground={this.setUnlockScreenKey}
handleAppComesToBackground={this.lockScreen}
/>
<PersistGate loading={null} persistor={persistor}>
<View style={styles.wrapper}>
<Navigator unlockKey={this.state.unlockKey} />
</View>
<NotificationsServices />
</PersistGate>
</Provider>
<Toast ref={ref => Toast.setRef(ref)} />
</I18nextProvider>
</>
);
}
}
export default Sentry.withTouchEventBoundary(App, {});
const styles = StyleSheet.create({
wrapper: {
flex: 1,
},
});