-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
83 lines (77 loc) · 2.3 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
/* eslint-disable import/no-named-as-default-member */
/* eslint-disable import/no-named-as-default */
import React from 'react';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/lib/integration/react';
import Toast from 'react-native-toast-message';
// db related
import { Database } from '@nozbe/watermelondb';
import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite';
import DatabaseProvider from '@nozbe/watermelondb/DatabaseProvider';
import codePush from 'react-native-code-push';
import * as Sentry from '@sentry/react-native';
import { store, persistor } from './src/redux/store';
import api from './src/api/config';
// models
import schema from './src/models/schema';
import migrations from './src/models/migrations';
import Node from './src/models/Node';
import Transaction from './src/models/Transaction';
import Product from './src/models/Product';
import Batch from './src/models/Batch';
import SourceBatch from './src/models/SourceBatch';
import TransactionPremium from './src/models/TransactionPremium';
import ProductPremium from './src/models/ProductPremium';
import Premium from './src/models/Premium';
import Card from './src/models/Card';
// screens
import Root from './src/screens/Root';
import ToastConfig from './src/components/ToastConfig';
if (__DEV__) {
import('./ReactotronConfig').then(() => 'Reactotron Configured');
} else {
Sentry.init({
dsn: api.SENTRY_URL,
});
}
const codePushOptions = {
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
};
const adapter = new SQLiteAdapter({
schema,
migrations,
jsi: true,
onSetUpError: () => {
// console.log('error', error);
},
});
// Then, make a Watermelon database from it!
export const database = new Database({
adapter,
modelClasses: [
Node,
Transaction,
Product,
Batch,
TransactionPremium,
Premium,
SourceBatch,
Card,
ProductPremium,
],
actionsEnabled: true,
});
const MyApp = () => {
return (
<DatabaseProvider database={database}>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Root />
</PersistGate>
</Provider>
<Toast config={ToastConfig} visibilityTime={2000} />
</DatabaseProvider>
);
};
const App = codePush(codePushOptions)(MyApp);
export default Sentry.wrap(App);