diff --git a/src/client/components/ComicDetail/ComicDetail.tsx b/src/client/components/ComicDetail/ComicDetail.tsx index af48dc2..89692db 100644 --- a/src/client/components/ComicDetail/ComicDetail.tsx +++ b/src/client/components/ComicDetail/ComicDetail.tsx @@ -34,6 +34,11 @@ import { styled } from "styled-components"; import { COMICVINE_SERVICE_URI } from "../../constants/endpoints"; import { refineQuery } from "filename-parser"; +// overridden with some styles - moved outside component to prevent recreation +const StyledSlidingPanel = styled(SlidingPane)` + background: #ccc; +`; + interface ComicDetailProps { data: { _id: string; @@ -98,11 +103,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => { // ); }, []); - // overridden with some styles - const StyledSlidingPanel = styled(SlidingPane)` - background: #ccc; - `; - const afterOpenModal = useCallback((things) => { + const afterOpenModal = useCallback((things: any) => { // references are now sync'd and can be accessed. // subtitle.style.color = "#f00"; console.log("kolaveri", things); diff --git a/src/client/components/ComicDetail/Tabs/ArchiveOperations.tsx b/src/client/components/ComicDetail/Tabs/ArchiveOperations.tsx index d1edfc9..48a33cc 100644 --- a/src/client/components/ComicDetail/Tabs/ArchiveOperations.tsx +++ b/src/client/components/ComicDetail/Tabs/ArchiveOperations.tsx @@ -14,34 +14,41 @@ import { useStore } from "../../../store"; import { useShallow } from "zustand/react/shallow"; import { escapePoundSymbol } from "../../../shared/utils/formatting.utils"; -export const ArchiveOperations = (props): ReactElement => { +export const ArchiveOperations = (props: { data: any }): ReactElement => { const { data } = props; - const { socketIOInstance } = useStore( - useShallow((state) => ({ - socketIOInstance: state.socketIOInstance, - })), - ); + const getSocket = useStore((state) => state.getSocket); const queryClient = useQueryClient(); // sliding panel config const [visible, setVisible] = useState(false); const [slidingPanelContentId, setSlidingPanelContentId] = useState(""); // current image - const [currentImage, setCurrentImage] = useState([]); - const [uncompressedArchive, setUncompressedArchive] = useState([]); - const [imageAnalysisResult, setImageAnalysisResult] = useState({}); + const [currentImage, setCurrentImage] = useState(""); + const [uncompressedArchive, setUncompressedArchive] = useState([]); + const [imageAnalysisResult, setImageAnalysisResult] = useState({}); const [shouldRefetchComicBookData, setShouldRefetchComicBookData] = useState(false); - const constructImagePaths = (data): Array => { + const constructImagePaths = (data: string[]): Array => { return data?.map((path: string) => escapePoundSymbol(encodeURI(`${LIBRARY_SERVICE_HOST}/${path}`)), ); }; // Listen to the uncompression complete event and orchestrate the final payload - socketIOInstance.on("LS_UNCOMPRESSION_JOB_COMPLETE", (data) => { - setUncompressedArchive(constructImagePaths(data?.uncompressedArchive)); - }); + useEffect(() => { + const socket = getSocket("/"); + if (!socket) return; + + const handleUncompressionComplete = (data: any) => { + setUncompressedArchive(constructImagePaths(data?.uncompressedArchive)); + }; + + socket.on("LS_UNCOMPRESSION_JOB_COMPLETE", handleUncompressionComplete); + + return () => { + socket.off("LS_UNCOMPRESSION_JOB_COMPLETE", handleUncompressionComplete); + }; + }, [getSocket]); useEffect(() => { let isMounted = true; @@ -58,7 +65,7 @@ export const ArchiveOperations = (props): ReactElement => { }, transformResponse: async (responseData) => { const parsedData = JSON.parse(responseData); - const paths = parsedData.map((pathObject) => { + const paths = parsedData.map((pathObject: any) => { return `${pathObject.containedIn}/${pathObject.name}${pathObject.extension}`; }); const uncompressedArchive = constructImagePaths(paths); @@ -131,7 +138,7 @@ export const ArchiveOperations = (props): ReactElement => { } // sliding panel init - const contentForSlidingPanel = { + const contentForSlidingPanel: Record JSX.Element }> = { imageAnalysis: { content: () => { return ( @@ -143,7 +150,7 @@ export const ArchiveOperations = (props): ReactElement => { ) : null}
-              {JSON.stringify(imageAnalysisResult.analyzedData, null, 2)}
+              {JSON.stringify(imageAnalysisResult?.analyzedData, null, 2)}
             
); @@ -152,7 +159,7 @@ export const ArchiveOperations = (props): ReactElement => { }; // sliding panel handlers - const openImageAnalysisPanel = useCallback((imageFilePath) => { + const openImageAnalysisPanel = useCallback((imageFilePath: string) => { setSlidingPanelContentId("imageAnalysis"); analyzeImage(imageFilePath); setCurrentImage(imageFilePath); diff --git a/src/client/components/ComicDetail/Tabs/ComicInfoXML.tsx b/src/client/components/ComicDetail/Tabs/ComicInfoXML.tsx index 3f18550..2c348ec 100644 --- a/src/client/components/ComicDetail/Tabs/ComicInfoXML.tsx +++ b/src/client/components/ComicDetail/Tabs/ComicInfoXML.tsx @@ -1,18 +1,18 @@ import { isUndefined } from "lodash"; import React, { ReactElement } from "react"; -export const ComicInfoXML = (data): ReactElement => { +export const ComicInfoXML = (data: { json: any }): ReactElement => { const { json } = data; return (
-

{json.series[0]}

+

{json.series?.[0]}

published by{" "} - {json.publisher[0]} + {json.publisher?.[0]}
@@ -30,18 +30,20 @@ export const ComicInfoXML = (data): ReactElement => { )} -
- {/* Genre */} - - - - + {/* Genre */} + {!isUndefined(json.genre) && ( +
+ + + + - - {json.genre[0]} + + {json.genre[0]} + - -
+ + )}
@@ -52,12 +54,14 @@ export const ComicInfoXML = (data): ReactElement => { )}
-
- {/* Notes */} - - {json.notes[0]} - -
+ {!isUndefined(json.notes) && ( +
+ {/* Notes */} + + {json.notes[0]} + +
+ )}
); diff --git a/src/client/components/Dashboard/RecentlyImported.tsx b/src/client/components/Dashboard/RecentlyImported.tsx index bd90c91..8c09e98 100644 --- a/src/client/components/Dashboard/RecentlyImported.tsx +++ b/src/client/components/Dashboard/RecentlyImported.tsx @@ -10,6 +10,7 @@ import { } from "../../shared/utils/metadata.utils"; import { LIBRARY_SERVICE_HOST } from "../../constants/endpoints"; import Header from "../shared/Header"; +import useEmblaCarousel from "embla-carousel-react"; type RecentlyImportedProps = { comics: any; @@ -19,6 +20,15 @@ export const RecentlyImported = ( comics: RecentlyImportedProps, ): ReactElement => { console.log(comics); + + // embla carousel + const [emblaRef, emblaApi] = useEmblaCarousel({ + loop: false, + align: "start", + containScroll: "trimSnaps", + slidesToScroll: 1, + }); + return (
-
- {comics?.comics.map( +
+
+
+ {comics?.comics.map( ( { _id, @@ -56,13 +68,16 @@ export const RecentlyImported = ( !isUndefined(comicvine) && !isUndefined(comicvine.volumeInformation); return ( - +
{/* Issue number */} @@ -99,16 +114,17 @@ export const RecentlyImported = (
{/* ComicInfo.xml presence */} {!isNil(comicInfo) && !isEmpty(comicInfo) && ( -
+
)} {/* ComicVine metadata presence */} {isComicVineMetadataAvailable && ( - + {"ComicVine )} @@ -121,9 +137,12 @@ export const RecentlyImported = ( )}
+
); }, )} +
+
); diff --git a/src/client/components/Dashboard/WantedComicsList.tsx b/src/client/components/Dashboard/WantedComicsList.tsx index 61ba8e1..7798961 100644 --- a/src/client/components/Dashboard/WantedComicsList.tsx +++ b/src/client/components/Dashboard/WantedComicsList.tsx @@ -102,7 +102,7 @@ export const WantedComicsList = ({ {"ComicVine )} {!isEmpty(locg) && ( diff --git a/src/client/components/Library/LibraryGrid.tsx b/src/client/components/Library/LibraryGrid.tsx index 04c7a85..b2e4f35 100644 --- a/src/client/components/Library/LibraryGrid.tsx +++ b/src/client/components/Library/LibraryGrid.tsx @@ -72,8 +72,11 @@ export const LibraryGrid = (libraryGridProps: ILibraryGridProps) => { >
{!isEmpty(sourcedMetadata.comicvine) && ( - - + + )} {isNil(rawFileDetails) && (