All files / middleware forwardToMain.js

100% Statements 9/9
100% Branches 9/9
100% Functions 3/3
100% Lines 6/6
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      5x 5x   4x                 1x       1x       3x        
import { ipcRenderer } from 'electron';
import validateAction from '../helpers/validateAction';
 
const forwardToMain = store => next => (action) => { // eslint-disable-line no-unused-vars
  if (!validateAction(action)) return next(action);
 
  if (
    action.type.substr(0, 2) !== '@@'
    && action.type.substr(0, 10) !== 'redux-form'
    && (
      !action.meta
      || !action.meta.scope
      || action.meta.scope !== 'local'
    )
  ) {
    ipcRenderer.send('redux-action', action);
 
    // stop action in-flight
    // eslint-disable-next-line consistent-return
    return next(action);
  }
 
  // eslint-disable-next-line consistent-return
  return next(action);
};
 
export default forwardToMain;