forked from forest-watcher/forest-watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (58 loc) · 2.01 KB
/
Copy pathindex.js
File metadata and controls
69 lines (58 loc) · 2.01 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
import { Platform, UIManager } from 'react-native';
import { Navigation } from 'react-native-navigation';
import App from './app/main.tsx';
import { disableAnalytics } from 'helpers/analytics';
global.Buffer = global.Buffer || require('buffer').Buffer;
// Don't enable animation support on Android, as it was causing strange UI issues (see https://3sidedcube.atlassian.net/browse/GFW-370)
if (Platform.OS === 'android') {
UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(false);
}
disableAnalytics(__DEV__);
const app = new App();
let hasSetupCompleted = false;
let setupInFlight = false;
let hasNavigationLaunchSignal = false;
const startAppSetup = async () => {
if (hasSetupCompleted || setupInFlight) {
return;
}
setupInFlight = true;
try {
await app.setupApp();
hasSetupCompleted = true;
} catch (err) {
// Keep retries enabled for app-launched/time-based fallbacks.
console.warn('WRI', 'setupApp failed, will retry', err);
} finally {
setupInFlight = false;
}
};
const onNavigationReady = () => {
if (hasNavigationLaunchSignal) {
return;
}
hasNavigationLaunchSignal = true;
if (typeof app.onNavigationReady === 'function') {
app.onNavigationReady();
}
startAppSetup();
};
// We'll setup the app whenever RNN tells us the app has safely launched
// See https://wix.github.io/react-native-navigation/#/docs/app-launch
try {
Navigation.events().registerAppLaunchedListener(() => {
onNavigationReady();
});
} catch (err) {
// Keep startup alive even if events emitter wiring fails.
console.warn('WRI', 'registerAppLaunchedListener failed; using delayed startup fallback', err);
}
// Fallback for edge-cases where app launched events are swallowed.
// Keep this intentionally late to avoid triggering Bridge-not-loaded redboxes.
setTimeout(() => {
if (!hasNavigationLaunchSignal) {
console.warn('WRI', 'onAppLaunched signal not observed; using delayed fallback');
onNavigationReady();
}
}, 8000);
export default app;