diff --git a/src/client/actions/airdcpp.actions.tsx b/src/client/actions/airdcpp.actions.tsx index 1e171a2..6c90e3e 100644 --- a/src/client/actions/airdcpp.actions.tsx +++ b/src/client/actions/airdcpp.actions.tsx @@ -194,32 +194,6 @@ export const downloadAirDCPPItem = } }; -export const getDownloadProgress = - (comicObjectId: string, ADCPPSocket: any, credentials: any): void => - async (dispatch) => { - try { - if (!ADCPPSocket.isConnected()) { - await ADCPPSocket.connect( - `${credentials.username}`, - `${credentials.password}`, - true, - ); - } - await ADCPPSocket.addListener( - `queue`, - "queue_bundle_tick", - async (downloadProgressData) => { - dispatch({ - type: AIRDCPP_DOWNLOAD_PROGRESS_TICK, - downloadProgressData, - }); - }, - ); - } catch (error) { - throw error; - } - }; - export const getBundlesForComic = (comicObjectId: string, ADCPPSocket: any, credentials: any) => async (dispatch) => { diff --git a/src/client/components/App.tsx b/src/client/components/App.tsx index 5aacc81..882b2e3 100644 --- a/src/client/components/App.tsx +++ b/src/client/components/App.tsx @@ -21,11 +21,13 @@ import { AirDCPPSocketContext, } from "../context/AirDCPPSocket"; import { isEmpty, isUndefined } from "lodash"; +import { AIRDCPP_DOWNLOAD_PROGRESS_TICK } from "../constants/action-types"; +import { useDispatch } from "react-redux"; const AirDCPPSocketComponent = (): ReactElement => { const airDCPPConfiguration = useContext(AirDCPPSocketContext); console.log(airDCPPConfiguration); - + const dispatch = useDispatch(); useEffect(() => { const foo = async () => { if ( @@ -38,6 +40,20 @@ const AirDCPPSocketComponent = (): ReactElement => { "queue_bundle_added", async (data) => console.log("JEMEN:", data), ); + // download tick listener + await airDCPPConfiguration.airDCPPState.socket.addListener( + `queue`, + "queue_bundle_tick", + async (downloadProgressData) => { + dispatch({ + type: AIRDCPP_DOWNLOAD_PROGRESS_TICK, + downloadProgressData, + }); + }, + ); + console.log( + "[AirDCPP]: Listener registered - listening to queue bundle download ticks", + ); console.log( "[AirDCPP]: Listener registered - listening to queue bundle changes", ); diff --git a/src/client/components/ComicDetail/DownloadProgressTick.tsx b/src/client/components/ComicDetail/DownloadProgressTick.tsx index 5eb524e..f28c6eb 100644 --- a/src/client/components/ComicDetail/DownloadProgressTick.tsx +++ b/src/client/components/ComicDetail/DownloadProgressTick.tsx @@ -3,7 +3,7 @@ import React, { ReactElement } from "react"; export const DownloadProgressTick = (props): ReactElement => { return ( -
{JSON.stringify(AirDCPPTransfers, null, 2)};
};
diff --git a/src/client/components/Navbar.tsx b/src/client/components/Navbar.tsx
index 72974d3..8f82211 100644
--- a/src/client/components/Navbar.tsx
+++ b/src/client/components/Navbar.tsx
@@ -2,8 +2,14 @@ import React from "react";
import { SearchBar } from "./GlobalSearchBar/SearchBar";
import { DownloadProgressTick } from "./ComicDetail/DownloadProgressTick";
import { Link } from "react-router-dom";
+import { useSelector } from "react-redux";
+import { isEmpty, isUndefined } from "lodash";
const Navbar: React.FunctionComponent = (props) => {
+ const downloadProgressTick = useSelector(
+ (state: RootState) => state.airdcpp.downloadProgressData,
+ );
+ console.log(downloadProgressTick)
return (