-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.js
62 lines (57 loc) · 1.75 KB
/
index.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
import './wrapper';
import * as RNIap from 'react-native-iap';
import { Navigation } from './thirdparty/react-native-navigation';
import { logger } from './thirdparty/react-native-logs';
import { rnFsFileAsync } from './thirdparty/react-native-logs/src/transports/rnFsFileAsync.ts';
import { colorConsoleSync } from './thirdparty/react-native-logs/src/transports/colorConsoleSync.ts';
import { registerScreens } from './screens';
import { setLoginAsRoot, setMainAsRoot } from './services/navigation';
import { startResourceLoader } from './services/resources_loader';
import api from './api';
import { iniI18nConfig } from './i18n';
import dataStore from './data_store';
import { setDefaultNavigationOptions } from './components/ThemeListener';
const defaultConfig = {
severity: 'debug',
transport: (msg, level, options) => {
colorConsoleSync(msg, level, options);
rnFsFileAsync(msg, level, options);
},
levels: {
debug: 0,
info: 1,
warn: 2,
error: 3,
},
};
const customLog = logger.createLogger(defaultConfig);
console.debug = customLog.debug;
console.info = customLog.info;
console.error = customLog.error;
console.warn = customLog.warn;
console.log = customLog.info;
const SyncStorage = require('sync-storage').default;
RNIap.initConnection().then((connect) => {
console.log('RNIap initConnection', connect);
});
registerScreens();
setDefaultNavigationOptions();
//
Navigation.events().registerAppLaunchedListener(async () => {
try {
await SyncStorage.init();
iniI18nConfig();
startResourceLoader();
const user = await api.localLogin();
if (user) {
await dataStore.initUser();
}
} catch (err) {
console.error(err);
}
if (api.isLoggedIn()) {
setMainAsRoot();
} else {
setLoginAsRoot();
}
});