From a5c02d3fc6d3154e074d69bd08c35fa51f3fc50c Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Wed, 23 Aug 2023 11:48:13 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Hardening=20the=20import=20UX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/components/Import.tsx | 18 ++++++++++++------ src/client/constants/action-types.ts | 9 ++++++--- src/client/reducers/fileops.reducer.ts | 15 +++++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/client/components/Import.tsx b/src/client/components/Import.tsx index 50cc147..25bef03 100644 --- a/src/client/components/Import.tsx +++ b/src/client/components/Import.tsx @@ -34,8 +34,8 @@ interface IProps { export const Import = (props: IProps): ReactElement => { const dispatch = useDispatch(); - const libraryQueueResults = useSelector( - (state: RootState) => state.fileOps.librarySearchResultCount, + const successfulImportJobCount = useSelector( + (state: RootState) => state.fileOps.successfulJobCount, ); const failedImportJobCount = useSelector( (state: RootState) => state.fileOps.failedJobCount, @@ -149,16 +149,16 @@ export const Import = (props: IProps): ReactElement => { - {libraryQueueResults && ( + {successfulImportJobCount > 0 && (
- {libraryQueueResults} + {successfulImportJobCount}
)} - {!isUndefined(failedImportJobCount) && ( + {failedImportJobCount > 0 && (
{failedImportJobCount} @@ -171,7 +171,13 @@ export const Import = (props: IProps): ReactElement => { - Imported {lastQueueJob} + {libraryQueueImportStatus !== "drained" && + !isUndefined(libraryQueueImportStatus) && ( + <> + Imported{" "} + {lastQueueJob} + + )}
); diff --git a/src/client/constants/action-types.ts b/src/client/constants/action-types.ts index cde0b74..7a69fbf 100644 --- a/src/client/constants/action-types.ts +++ b/src/client/constants/action-types.ts @@ -51,11 +51,12 @@ export const IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS = "IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS"; export const IMS_COMIC_BOOK_GROUPS_CALL_FAILED = "IMS_COMIC_BOOK_GROUPS_CALL_FAILED"; -export const VOLUMES_FETCHED="VOLUMES_FETCHED"; +export const VOLUMES_FETCHED = "VOLUMES_FETCHED"; // search results from the Search service export const SS_SEARCH_RESULTS_FETCHED = "SS_SEARCH_RESULTS_FETCHED"; -export const SS_SEARCH_RESULTS_FETCHED_SPECIAL = "SS_SEARCH_RESULTS_FETCHED_SPECIAL"; +export const SS_SEARCH_RESULTS_FETCHED_SPECIAL = + "SS_SEARCH_RESULTS_FETCHED_SPECIAL"; export const SS_SEARCH_IN_PROGRESS = "SS_SEARCH_IN_PROGRESS"; export const SS_SEARCH_FAILED = "SS_SEARCH_FAILED"; @@ -124,13 +125,15 @@ export const AIRDCPP_TRANSFERS_FETCHED = "AIRDCPP_TRANSFERS_FETCHED"; // Comics marked as "wanted" export const WANTED_COMICS_FETCHED = "WANTED_COMICS_FETCHED"; -// LIBRARY SOCKET ENDPOINT +// LIBRARY Service import queue-related action types export const LS_IMPORT = "LS_IMPORT"; export const LS_COVER_EXTRACTED = "LS_COVER_EXTRACTED"; export const LS_COVER_EXTRACTION_FAILED = "LS_COVER_EXTRACTION_FAILED"; export const LS_COMIC_ADDED = "LS_COMIC_ADDED"; export const LS_IMPORT_QUEUE_DRAINED = "LS_IMPORT_QUEUE_DRAINED"; export const LS_SET_QUEUE_STATUS = "LS_SET_QUEUE_STATUS"; +export const RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION = + "RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION"; // Settings export const SETTINGS_CALL_IN_PROGRESS = "SETTINGS_CALL_IN_PROGRESS"; diff --git a/src/client/reducers/fileops.reducer.ts b/src/client/reducers/fileops.reducer.ts index 2ff706f..7073e90 100644 --- a/src/client/reducers/fileops.reducer.ts +++ b/src/client/reducers/fileops.reducer.ts @@ -35,6 +35,7 @@ import { HEALTH_STATUS_TICK, LS_IMPORT_QUEUE_DRAINED, LS_SET_QUEUE_STATUS, + RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION, } from "../constants/action-types"; import { removeLeadingPeriod } from "../shared/utils/formatting.utils"; import { LIBRARY_SERVICE_HOST } from "../constants/endpoints"; @@ -62,7 +63,7 @@ const initialState = { volumes: [], librarySearchResultsFormatted: [], lastQueueJob: "", - librarySearchResultCount: 0, + successfulJobCount: 0, failedJobCount: 0, libraryQueueResults: [], librarySearchError: {}, @@ -160,21 +161,20 @@ function fileOpsReducer(state = initialState, action) { LSQueueImportStatus: "running", }; } + case LS_COVER_EXTRACTED: { - console.log("BASH", action); if (state.recentComics.length === 5) { state.recentComics.pop(); } return { ...state, - librarySearchResultCount: action.completedJobCount, + successfulJobCount: action.completedJobCount, lastQueueJob: action.importResult.rawFileDetails.name, recentComics: [...state.recentComics, action.importResult], }; } case LS_COVER_EXTRACTION_FAILED: { - console.log("FAILED", action); return { ...state, failedJobCount: action.failedJobCount, @@ -182,19 +182,18 @@ function fileOpsReducer(state = initialState, action) { } case LS_IMPORT_QUEUE_DRAINED: { - console.log("drained"); return { ...state, LSQueueImportStatus: "drained", }; } - case "RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION": { - console.log(action); + case RESTORE_JOB_COUNTS_AFTER_SESSION_RESTORATION: { return { ...state, - librarySearchResultCount: action.completedJobCount, + successfulJobCount: action.completedJobCount, failedJobCount: action.failedJobCount, + LSQueueImportStatus: action.queueStatus, }; }