import { all, call, takeLatest } from "redux-saga/effects";
import ipcTypes from "../../ipc.types";
import ScanActionTypes from "./scan.types";

const { ipcRenderer } = window;

export function* onScanStart() {
  yield takeLatest(ScanActionTypes.SCAN_START, handleScanStart);
}

// eslint-disable-next-line require-yield
export function* handleScanStart() {
  ipcRenderer.send(ipcTypes.fileScan.toMain.scanFilePaths);
}

export function* scanSagas() {
  yield all([call(onScanStart)]);
}
