diff --git a/src/client/components/App.tsx b/src/client/components/App.tsx index be7d7f3..9e46773 100644 --- a/src/client/components/App.tsx +++ b/src/client/components/App.tsx @@ -22,13 +22,6 @@ import { LS_SINGLE_IMPORT, } from "../constants/action-types"; -/** - * Method that initializes an AirDC++ socket connection - * 1. Initializes event listeners for download init, tick and complete events - * 2. Handles errors in case the connection to AirDC++ is not established or terminated - * @returns void - */ - export const App = (): ReactElement => { // useEffect(() => { // // Check if there is a sessionId in localStorage diff --git a/src/client/components/Import/Import.tsx b/src/client/components/Import/Import.tsx index 7a9d4fd..36d7471 100644 --- a/src/client/components/Import/Import.tsx +++ b/src/client/components/Import/Import.tsx @@ -40,16 +40,7 @@ export const Import = (props: IProps): ReactElement => { socketIOInstance: state.socketIOInstance, })), ); - // const successfulImportJobCount = useSelector( - // (state: RootState) => state.fileOps.successfulJobCount, - // ); - // const failedImportJobCount = useSelector( - // (state: RootState) => state.fileOps.failedJobCount, - // ); - // - // const lastQueueJob = useSelector( - // (state: RootState) => state.fileOps.lastQueueJob, - // ); + // const libraryQueueImportStatus = useSelector( // (state: RootState) => state.fileOps.LSQueueImportStatus, // ); @@ -68,17 +59,23 @@ export const Import = (props: IProps): ReactElement => { }), }); - // Act on each comic issue successfully imported, as indicated - // by the LS_COVER_EXTRACTED event + // 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 } = data; + const { completedJobCount, importResult } = data; importJobQueue.setJobCount("successful", completedJobCount); + importJobQueue.setMostRecentImport(importResult.rawFileDetails.name); }); socketIOInstance.on("LS_COVER_EXTRACTION_FAILED", (data) => { - console.log(data); const { failedJobCount } = data; importJobQueue.setJobCount("failed", failedJobCount); }); + + // 1b. Clear the localStorage sessionId upon receiving the + // LS_IMPORT_QUEUE_DRAINED event + socketIOInstance.on("LS_IMPORT_QUEUE_DRAINED", (data) => { + localStorage.removeItem("sessionId"); + }); const toggleQueue = useCallback( (queueAction: string, queueStatus: string) => { // dispatch(setQueueControl(queueAction, queueStatus)); @@ -205,7 +202,9 @@ export const Import = (props: IProps): ReactElement => { Imported{" "} - {/* {lastQueueJob} */} + + {importJobQueue.mostRecentImport} + {/* Past imports */} diff --git a/src/client/components/shared/Navbar.tsx b/src/client/components/shared/Navbar.tsx index a010258..ba07168 100644 --- a/src/client/components/shared/Navbar.tsx +++ b/src/client/components/shared/Navbar.tsx @@ -56,7 +56,7 @@ const Navbar: React.FunctionComponent = (props) => { return (