Importing will add comics identified from the mapped folder into ThreeTwo's database. @@ -195,78 +173,73 @@ export const Import = (props: IProps): ReactElement => { Start Import
*/} -| Completed Jobs | -Failed Jobs | -Queue Controls | -Queue Status | -
|---|---|---|---|
|
- {importJobQueue.successfulJobCount > 0 && (
-
-
- {importJobQueue.successfulJobCount}
-
-
- )}
- |
-
- {importJobQueue.failedJobCount > 0 && (
-
-
- {importJobQueue.failedJobCount}
-
-
- )}
- |
-
- {renderQueueControls(importJobQueue.status)} | -- {importJobQueue.status !== undefined ? ( - - {importJobQueue.status} - - ) : null} - | -
-
{/* Settings Icon and text */}
- - Settings - +
- diff --git a/src/client/store/index.ts b/src/client/store/index.ts index eb5b5c1..bc836c3 100644 --- a/src/client/store/index.ts +++ b/src/client/store/index.ts @@ -5,6 +5,7 @@ import { SOCKET_BASE_URI } from "../constants/endpoints"; import { produce } from "immer"; import AirDCPPSocket from "../services/DcppSearchService"; import axios from "axios"; +import { QueryClient } from "@tanstack/react-query"; /* Broadly, this file sets up: * 1. The zustand-based global client state @@ -69,6 +70,7 @@ export const useStore = create((set, get) => ({ })); const { getState, setState } = useStore; +const queryClient = new QueryClient(); /** Socket.IO initialization **/ // 1. Fetch sessionId from localStorage @@ -115,6 +117,42 @@ socketIOInstance.on("RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION", (data) => { })); }); +// 1a. Act on each comic issue successfully imported/failed, as indicated +// by the LS_COVER_EXTRACTED/LS_COVER_EXTRACTION_FAILED events +socketIOInstance.on("LS_COVER_EXTRACTED", (data) => { + const { completedJobCount, importResult } = data; + setState((state) => ({ + importJobQueue: { + ...state.importJobQueue, + successfulJobCount: completedJobCount, + mostRecentImport: importResult.rawFileDetails.name, + }, + })); +}); +socketIOInstance.on("LS_COVER_EXTRACTION_FAILED", (data) => { + const { failedJobCount } = data; + setState((state) => ({ + importJobQueue: { + ...state.importJobQueue, + failedJobCount, + }, + })); +}); + +// 1b. Clear the localStorage sessionId upon receiving the +// LS_IMPORT_QUEUE_DRAINED event +socketIOInstance.on("LS_IMPORT_QUEUE_DRAINED", (data) => { + localStorage.removeItem("sessionId"); + setState((state) => ({ + importJobQueue: { + ...state.importJobQueue, + status: "drained", + }, + })); + console.log("a", queryClient); + queryClient.invalidateQueries({ queryKey: ["allImportJobResults"] }); +}); + /** * Method to init AirDC++ Socket with supplied settings * @param configuration - credentials, and hostname details to init AirDC++ connection