From 0e72d6400912c641c689bf14684e1c50c14782be Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 17 Jan 2023 20:10:12 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8C=20Setting=20autoReconnect=20to=20t?= =?UTF-8?q?rue=20in=20the=20ADCPP=20constructor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/actions/airdcpp.actions.tsx | 27 ++++++++++++++++++------ src/client/components/Navbar.tsx | 19 +++++++++++------ src/client/context/AirDCPPSocket.tsx | 8 ++++--- src/client/services/DcppSearchService.ts | 4 +++- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/client/actions/airdcpp.actions.tsx b/src/client/actions/airdcpp.actions.tsx index bea68dd..b279a78 100644 --- a/src/client/actions/airdcpp.actions.tsx +++ b/src/client/actions/airdcpp.actions.tsx @@ -37,12 +37,27 @@ function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } -export const setAirDCPPSocketConnectionAsActive = () => async (dispatch) => { - console.log("fire, fire, fire"); - dispatch({ - type: AIRDCPP_SOCKET_CONNECTED, - }); -}; +export const toggleAirDCPPSocketConnectionStatus = + (status: String) => async (dispatch) => { + console.log("sanul", status); + switch (status) { + case "connected": + dispatch({ + type: AIRDCPP_SOCKET_CONNECTED, + }); + break; + + case "disconnected": + dispatch({ + type: AIRDCPP_SOCKET_DISCONNECTED, + }); + break; + + default: + console.log("Can't set AirDC++ socket status."); + break; + } + }; export const search = (data: SearchData, ADCPPSocket: any, credentials: any) => async (dispatch) => { diff --git a/src/client/components/Navbar.tsx b/src/client/components/Navbar.tsx index f5d47c3..095a5c0 100644 --- a/src/client/components/Navbar.tsx +++ b/src/client/components/Navbar.tsx @@ -10,9 +10,10 @@ const Navbar: React.FunctionComponent = (props) => { (state: RootState) => state.airdcpp.downloadProgressData, ); - // const airDCPPSocketConnectionStatus = useSelector((state: RootState) => { - // console.log(state); - // }); + const airDCPPSocketConnectionStatus = useSelector((state: RootState) => { + console.log(state); + return state.airdcpp.isAirDCPPSocketConnected; + }); return (