diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index e46f537..486530d 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -35,6 +35,7 @@ import { VOLUMES_FETCHED, CV_WEEKLY_PULLLIST_FETCHED, LIBRARY_SERVICE_HEALTH, + LS_SET_QUEUE_STATUS, } from "../constants/action-types"; import { success } from "react-notification-system-redux"; @@ -96,13 +97,14 @@ export const fetchComicBookMetadata = () => async (dispatch) => { data: {}, }); }; -export const toggleImportQueueStatus = (options) => async (dispatch) => { - dispatch({ - type: LS_TOGGLE_IMPORT_QUEUE, - meta: { remote: true }, - data: { manjhul: "jigyadam", action: options.action }, - }); -}; +export const setQueueControl = + (queueAction: string, queueStatus: string) => async (dispatch) => { + dispatch({ + type: LS_SET_QUEUE_STATUS, + meta: { remote: true }, + data: { queueAction, queueStatus }, + }); + }; /** * Fetches comic book metadata for various types * @return metadata for the comic book object categories diff --git a/src/client/components/App.tsx b/src/client/components/App.tsx index 264b8d2..71e5f9b 100644 --- a/src/client/components/App.tsx +++ b/src/client/components/App.tsx @@ -108,9 +108,6 @@ export const App = (): ReactElement => { meta: { remote: true }, session: { sessionId }, }); - socketIOConnectionInstance.on("yelaveda", (data) => { - console.log(data); - }); } else { // Inititalize the session and persist the sessionId to localStorage socketIOConnectionInstance.on("sessionInitialized", (sessionId) => { diff --git a/src/client/components/Downloads/Downloads.tsx b/src/client/components/Downloads/Downloads.tsx index a18eafe..3c619ed 100644 --- a/src/client/components/Downloads/Downloads.tsx +++ b/src/client/components/Downloads/Downloads.tsx @@ -1,4 +1,10 @@ -import React, { ReactElement, useCallback, useContext, useEffect, useState } from "react"; +import React, { + ReactElement, + useCallback, + useContext, + useEffect, + useState, +} from "react"; import { getTransfers } from "../../actions/airdcpp.actions"; import { useDispatch, useSelector } from "react-redux"; import { AirDCPPSocketContext } from "../../context/AirDCPPSocket"; @@ -20,7 +26,9 @@ export const Downloads = (props: IDownloadsProps): ReactElement => { const airDCPPTransfers = useSelector( (state: RootState) => state.airdcpp.transfers, ); - const issueBundles = useSelector((state: RootState) => state.airdcpp.issue_bundles); + const issueBundles = useSelector( + (state: RootState) => state.airdcpp.issue_bundles, + ); const [bundles, setBundles] = useState([]); // Make the call to get all transfers from AirDC++ useEffect(() => { @@ -37,18 +45,26 @@ export const Downloads = (props: IDownloadsProps): ReactElement => { useEffect(() => { if (!isUndefined(issueBundles)) { const foo = issueBundles.data.map((bundle) => { - const { rawFileDetails, inferredMetadata, acquisition: { directconnect: { downloads } }, sourcedMetadata: { locg, comicvine } } = bundle; + const { + rawFileDetails, + inferredMetadata, + acquisition: { + directconnect: { downloads }, + }, + sourcedMetadata: { locg, comicvine }, + } = bundle; const { issueName, url } = determineCoverFile({ - rawFileDetails, comicvine, locg, + rawFileDetails, + comicvine, + locg, }); - return { ...bundle, issueName, url } - - }) + return { ...bundle, issueName, url }; + }); setBundles(foo); } - }, [issueBundles]) + }, [issueBundles]); - return !isNil(bundles) ? + return !isNil(bundles) ? (
| Name | -Size | -Type | -Bundle ID | -
|---|---|---|---|
| {bundle.name} | -{bundle.size} | -{bundle.type.str} | -{bundle.bundleId} | -
{JSON.stringify(bundle.acquisition.directconnect.downloads, null, 2)} */}
- | Name | +Size | +Type | +Bundle ID | +
|---|---|---|---|
| {bundle.name} | +{bundle.size} | +{bundle.type.str} | ++ + {bundle.bundleId} + + | +
{JSON.stringify(bundle.acquisition.directconnect.downloads, null, 2)} */}
+ {props.subHeaderContent}
+ > + ); +}; - return (<> -- {props.subHeaderContent} -
- >) - -} - -export default Header; \ No newline at end of file +export default Header; diff --git a/src/client/components/Import.tsx b/src/client/components/Import.tsx index 79a4d37..50cc147 100644 --- a/src/client/components/Import.tsx +++ b/src/client/components/Import.tsx @@ -2,11 +2,15 @@ import React, { ReactElement, useCallback, useContext, useState } from "react"; import { useSelector, useDispatch } from "react-redux"; import { fetchComicBookMetadata, - toggleImportQueueStatus, + setQueueControl, } from "../actions/fileops.actions"; import "react-loader-spinner/dist/loader/css/react-spinner-loader.css"; import Loader from "react-loader-spinner"; import { isUndefined } from "lodash"; +import { + LS_IMPORT_CALL_IN_PROGRESS, + LS_SET_QUEUE_STATUS, +} from "../constants/action-types"; interface IProps { matches?: unknown; @@ -34,40 +38,62 @@ export const Import = (props: IProps): ReactElement => { (state: RootState) => state.fileOps.librarySearchResultCount, ); const failedImportJobCount = useSelector( - (state: RootState) => state.fileOps.failedImportJobCount, + (state: RootState) => state.fileOps.failedJobCount, ); const lastQueueJob = useSelector( (state: RootState) => state.fileOps.lastQueueJob, ); const libraryQueueImportStatus = useSelector( - (state: RootState) => state.fileOps.IMSCallInProgress, + (state: RootState) => state.fileOps.LSQueueImportStatus, ); - const [isImportQueuePaused, setImportQueueStatus] = useState(undefined); + const initiateImport = useCallback(() => { if (typeof props.path !== "undefined") { dispatch(fetchComicBookMetadata(props.path)); } }, [dispatch]); - const toggleImport = useCallback(() => { - setImportQueueStatus(!isImportQueuePaused); - if (isImportQueuePaused === true) { - dispatch(toggleImportQueueStatus({ action: "resume" })); - } else if (isImportQueuePaused === false) { - dispatch(toggleImportQueueStatus({ action: "pause" })); + const toggleQueue = useCallback( + (queueAction: string, queueStatus: string) => { + dispatch(setQueueControl(queueAction, queueStatus)); + }, + [], + ); + + const renderQueueControls = (status: string): ReactElement | null => { + switch (status) { + case "running": + return ( +