2017-09-25 21:32:58 +00:00
|
|
|
import * as React from 'react';
|
2017-02-26 21:12:51 +00:00
|
|
|
import ReactDOM from 'react-dom';
|
2017-03-03 01:44:07 +00:00
|
|
|
import {AppContainer} from 'react-hot-loader';
|
2016-11-07 20:24:38 +00:00
|
|
|
import {Provider} from 'react-redux';
|
2017-03-12 00:31:23 +00:00
|
|
|
import {DragDropContext} from 'react-dnd';
|
2017-03-08 05:52:17 +00:00
|
|
|
import App from './containers/app';
|
2017-08-23 03:33:07 +00:00
|
|
|
import * as models from '../models';
|
|
|
|
import {types as modelTypes} from '../models';
|
2016-11-16 17:18:39 +00:00
|
|
|
import {init as initStore} from './redux/modules';
|
|
|
|
import {init as initDB} from '../common/database';
|
|
|
|
import {init as initSync} from '../sync';
|
|
|
|
import {init as initAnalytics} from '../analytics';
|
2017-06-01 02:04:27 +00:00
|
|
|
import {init as initPlugins} from '../plugins';
|
2016-11-30 03:55:27 +00:00
|
|
|
import {getAccountId} from '../sync/session';
|
2017-03-12 00:31:23 +00:00
|
|
|
import DNDBackend from './dnd-backend';
|
|
|
|
import './css/index.less';
|
2017-08-23 03:33:07 +00:00
|
|
|
import {isDevelopment} from '../common/constants';
|
2016-03-16 05:49:42 +00:00
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
(async function () {
|
2016-11-30 03:55:27 +00:00
|
|
|
await initDB(modelTypes());
|
|
|
|
await initAnalytics(getAccountId());
|
|
|
|
|
|
|
|
// Create Redux store
|
|
|
|
const store = await initStore();
|
|
|
|
|
2017-03-12 00:31:23 +00:00
|
|
|
const context = DragDropContext(DNDBackend);
|
2017-03-03 01:44:07 +00:00
|
|
|
const DndComponent = context(App);
|
|
|
|
const render = Component => {
|
|
|
|
ReactDOM.render(
|
|
|
|
<AppContainer>
|
|
|
|
<Provider store={store}>
|
|
|
|
<Component/>
|
|
|
|
</Provider>
|
|
|
|
</AppContainer>,
|
|
|
|
document.getElementById('root')
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
render(DndComponent);
|
|
|
|
|
|
|
|
// Hot Module Replacement API
|
|
|
|
if (module.hot) {
|
2017-03-09 06:23:23 +00:00
|
|
|
module.hot.accept('./containers/app', () => {
|
2017-03-03 01:44:07 +00:00
|
|
|
render(DndComponent);
|
|
|
|
});
|
|
|
|
}
|
2016-11-30 03:55:27 +00:00
|
|
|
|
|
|
|
// Do things that can wait
|
|
|
|
process.nextTick(initSync);
|
2017-09-17 14:04:46 +00:00
|
|
|
process.nextTick(initPlugins);
|
2016-10-02 20:57:00 +00:00
|
|
|
})();
|
2017-08-23 03:33:07 +00:00
|
|
|
|
|
|
|
// Export some useful things for dev
|
|
|
|
if (isDevelopment()) {
|
|
|
|
window.models = models;
|
|
|
|
}
|