import * as Constants from '../../constants';
import {createAction} from 'redux-starter-kit';
import {getIPCRenderer} from '../../utils';

const ipcRenderer = getIPCRenderer();

export const setApplicationReady = createAction('common/setApplicationReady');

export const showWindow = () => {
  return dispatch => {
    if (ipcRenderer) {
      ipcRenderer.send(Constants.IPC_Show_Window);
    }
  };
};

export const shutdownApplication = () => {
  return dispatch => {
    dispatch(setApplicationReady(false));
    if (ipcRenderer) {
      ipcRenderer.send(Constants.IPC_Shutdown);
    }
  };
};