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 (
@@ -86,6 +98,9 @@ export const Import = (props: IProps): ReactElement => {

{JSON.stringify(libraryQueueResults, null, 2)}
+
); diff --git a/src/client/constants/action-types.ts b/src/client/constants/action-types.ts index 004f20c..50146e4 100644 --- a/src/client/constants/action-types.ts +++ b/src/client/constants/action-types.ts @@ -12,6 +12,8 @@ export const IMS_RAW_IMPORT_FAILED = "IMS_RAW_IMPORT_FAILED"; // Library service generic action types export const LS_IMPORT_CALL_IN_PROGRESS = "LS_IMPORT_CALL_IN_PROGRESS"; +// Library import bull mq queue control +export const LS_TOGGLE_IMPORT_QUEUE = "LS_TOGGLE_IMPORT_QUEUE"; // ComicVine Metadata export const IMS_CV_METADATA_IMPORT_CALL_IN_PROGRESS = diff --git a/yarn.lock b/yarn.lock index c968617..0c9b01a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -990,13 +990,20 @@ core-js-pure "^3.20.2" regenerator-runtime "^0.13.4" -"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.0", "@babel/runtime@^7.12.1", "@babel/runtime@^7.13.10", "@babel/runtime@^7.13.17", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.16.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": +"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.0", "@babel/runtime@^7.12.1", "@babel/runtime@^7.13.10", "@babel/runtime@^7.13.17", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.7.tgz#03ff99f64106588c9c403c6ecb8c3bafbbdff1fa" integrity sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ== dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.16.5": + version "7.17.7" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.7.tgz#a5f3328dc41ff39d803f311cfe17703418cf9825" + integrity sha512-L6rvG9GDxaLgFjg41K+5Yv9OMrU98sWe+Ykmc6FDJW/+vYZMhdOMKkISgzptMaERHvS2Y2lw9MDRm2gHhlQQoA== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.16.7", "@babel/template@^7.3.3": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155"