diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index 596f3a5..382e58e 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -28,6 +28,7 @@ import { SS_SEARCH_IN_PROGRESS, FILEOPS_STATE_RESET, LS_IMPORT_CALL_IN_PROGRESS, + LS_TOGGLE_IMPORT_QUEUE, } from "../constants/action-types"; import { success } from "react-notification-system-redux"; import { isNil, map } from "lodash"; @@ -88,7 +89,13 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => { data: { extractionOptions }, }); }; - +export const toggleImportQueueStatus = (options) => async (dispatch) => { + dispatch({ + type: LS_TOGGLE_IMPORT_QUEUE, + meta: { remote: true }, + data: { manjhul: "jigyadam", action: options.action }, + }); +}; export const getComicBooks = (options) => async (dispatch) => { const { paginationOptions, predicate, comicStatus } = options; diff --git a/src/client/components/Import.tsx b/src/client/components/Import.tsx index 91fe2bd..9411c0b 100644 --- a/src/client/components/Import.tsx +++ b/src/client/components/Import.tsx @@ -1,7 +1,9 @@ -import React, { ReactElement, useCallback, useContext } from "react"; -import { isEmpty } from "lodash"; +import React, { ReactElement, useCallback, useContext, useState } from "react"; import { useSelector, useDispatch } from "react-redux"; -import { fetchComicBookMetadata } from "../actions/fileops.actions"; +import { + fetchComicBookMetadata, + toggleImportQueueStatus, +} from "../actions/fileops.actions"; import DynamicList, { createCache } from "react-window-dynamic-list"; import "react-loader-spinner/dist/loader/css/react-spinner-loader.css"; import Loader from "react-loader-spinner"; @@ -34,12 +36,22 @@ export const Import = (props: IProps): ReactElement => { const libraryQueueImportStatus = useSelector( (state: RootState) => state.fileOps.IMSCallInProgress, ); + const [isImportQueuePaused, setImportQueueStatus] = useState(false); const initiateImport = useCallback(() => { if (typeof props.path !== "undefined") { dispatch(fetchComicBookMetadata(props.path)); } }, [dispatch]); + const toggleImport = useCallback(() => { + setImportQueueStatus(!isImportQueuePaused); + if (isImportQueuePaused === false) { + dispatch(toggleImportQueueStatus({ action: "resume" })); + } else if (isImportQueuePaused === true) { + dispatch(toggleImportQueueStatus({ action: "pause" })); + } + }, [isImportQueuePaused]); + return (
{JSON.stringify(libraryQueueResults, null, 2)}
+