diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index 7bb334a..84430c5 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -47,6 +47,7 @@ export const fetchComicBookMetadata = (options) => async (dispatch) => { console.log(`connect ${socket.id}`); dispatch({ type: IMS_SOCKET_CONNECTION_CONNECTED, + socketConnected: true, }); }); diff --git a/src/client/components/Card.tsx b/src/client/components/Card.tsx index 76e29f4..aaf741a 100644 --- a/src/client/components/Card.tsx +++ b/src/client/components/Card.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { IExtractedComicBookCoverFile } from "../../server/interfaces/folder.interface"; import { map } from "lodash"; diff --git a/src/client/components/Dashboard.tsx b/src/client/components/Dashboard.tsx index 777addd..ce9ab4f 100644 --- a/src/client/components/Dashboard.tsx +++ b/src/client/components/Dashboard.tsx @@ -7,19 +7,21 @@ interface IState {} class Dashboard extends React.Component { public render() { return ( -
-

Dashboard

-

- A simple container to divide your page into sections, - like the one you're currently reading. -

- -
+
+
+

Dashboard

+

+ A simple container to divide your page into{" "} + sections, like the one you're currently reading. +

+ +
+
); } } diff --git a/src/client/components/Import.tsx b/src/client/components/Import.tsx index c3fc511..89ac8e0 100644 --- a/src/client/components/Import.tsx +++ b/src/client/components/Import.tsx @@ -5,6 +5,7 @@ import { fetchComicBookMetadata } from "../actions/fileops.actions"; import { IFolderData } from "../shared/interfaces/comicinfo.interfaces"; import Card from "./Card"; import { io, Socket } from "socket.io-client"; +import { SOCKET_BASE_URI } from "../constants/endpoints"; interface IProps { matches: unknown; @@ -25,13 +26,6 @@ class Import extends React.Component { folderWalkResults: [], searchPaneIndex: undefined, }; - socket = io("ws://localhost:3000/", { - reconnectionDelayMax: 10000, - }); - - socket.on("connect", () => { - console.log(`connect ${socket.id}`); - }); } public toggleSearchResultsPane(paneId: number): void { @@ -42,6 +36,13 @@ class Import extends React.Component { public initiateSocketConnection = () => { if (typeof this.props.path !== "undefined") { + socket = io(SOCKET_BASE_URI, { + reconnectionDelayMax: 10000, + }); + + socket.on("connect", () => { + console.log(`connect ${socket.id}`); + }); this.props.fetchComicMetadata(); } }; diff --git a/src/client/components/Navbar.tsx b/src/client/components/Navbar.tsx index db2a2ca..9a7b633 100644 --- a/src/client/components/Navbar.tsx +++ b/src/client/components/Navbar.tsx @@ -1,7 +1,10 @@ -import * as React from "react"; +import React from "react"; +import { useSelector } from "react-redux"; import { Link } from "react-router-dom"; const Navbar: React.FunctionComponent = (props) => { + const socketConnected = useSelector((state) => state.fileOps); + return (