All files / helpers replayActionRenderer.js

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20        1x 3x 1x     2x             2x      
import { ipcRenderer } from 'electron';
import validateAction from './validateAction';
 
export default function replayActionRenderer(store) {
  ipcRenderer.on('redux-action', (event, payload) => {
    if (!validateAction(payload)) {
      return;
    }
    // to avoid endless-loop
    const rendererAction = {
      ...payload,
      meta: {
        ...payload.meta,
        scope: 'local',
      },
    };
    store.dispatch(rendererAction);
  });
}