import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import createAppStore from './redux/store/createAppStore';
import packageJson from '../package.json';
import {Provider} from 'react-redux';
import * as serviceWorker from './serviceWorker';

const Constants = require('./constants');

if (!process.versions.hasOwnProperty('electron')) {
  const ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
  if (ipcRenderer) {
    ipcRenderer.on(Constants.IPC_Get_Platform_Reply, (event, arg) => {
      if (arg.Platform === 'linux') {
        const root = document.documentElement;
        root.style.setProperty('--default_font_size', '15px');
      }

      const store = createAppStore(arg.Platform, arg.AppPlatform);
      ReactDOM.render((
        <Provider store={store}>
          <App version={packageJson.version}/>
        </Provider>
      ), document.getElementById('root'));
      serviceWorker.unregister();
    });
    ipcRenderer.send(Constants.IPC_Get_Platform);
  }
}

