dispatch/client/js/index.js

36 lines
984 B
JavaScript
Raw Normal View History

import './hot';
2015-12-28 23:34:32 +00:00
import React from 'react';
import { render } from 'react-dom';
2017-02-16 02:55:50 +00:00
import Root from 'components/Root';
2018-11-06 10:13:32 +00:00
import { appSet } from 'state/app';
import initRouter from 'utils/router';
import Socket from 'utils/Socket';
2015-12-28 23:34:32 +00:00
import configureStore from './store';
import routes from './routes';
2017-05-19 05:29:44 +00:00
import runModules from './modules';
2018-11-06 10:13:32 +00:00
import { register } from './serviceWorker';
2018-04-13 18:47:39 +00:00
import '../css/fonts.css';
import '../css/style.css';
2015-12-28 23:34:32 +00:00
const production = process.env.NODE_ENV === 'production';
2018-04-05 23:46:22 +00:00
const host = production
? window.location.host
: `${window.location.hostname}:1337`;
const socket = new Socket(host);
const store = configureStore(socket);
2017-05-19 05:29:44 +00:00
initRouter(routes, store);
runModules({ store, socket });
render(<Root store={store} />, document.getElementById('root'));
2018-11-06 10:13:32 +00:00
window.addEventListener('beforeinstallprompt', e => {
e.preventDefault();
store.dispatch(appSet('installable', e));
});
2018-11-06 10:13:32 +00:00
register({
onUpdate: () => store.dispatch(appSet('newVersionAvailable', true))
});