diff --git a/src/client/actions/settings.actions.tsx b/src/client/actions/settings.actions.tsx index 3a85216..194506f 100644 --- a/src/client/actions/settings.actions.tsx +++ b/src/client/actions/settings.actions.tsx @@ -1,7 +1,6 @@ import axios from "axios"; import { SETTINGS_OBJECT_FETCHED, - SETTINGS_OBJECT_DELETED, SETTINGS_CALL_IN_PROGRESS, SETTINGS_DB_FLUSH_SUCCESS, } from "../constants/action-types"; @@ -10,18 +9,19 @@ import { SETTINGS_SERVICE_BASE_URI, } from "../constants/endpoints"; -export const saveSettings = (settingsPayload) => async (dispatch) => { - const result = await axios({ - url: `${SETTINGS_SERVICE_BASE_URI}/saveSettings`, - method: "POST", - data: { settingsPayload }, - }); - console.log(result.data); - dispatch({ - type: SETTINGS_OBJECT_FETCHED, - data: result.data, - }); -}; +export const saveSettings = + (settingsPayload, settingsObjectId?: string) => async (dispatch) => { + const result = await axios({ + url: `${SETTINGS_SERVICE_BASE_URI}/saveSettings`, + method: "POST", + data: { settingsPayload, settingsObjectId }, + }); + console.log(result.data); + dispatch({ + type: SETTINGS_OBJECT_FETCHED, + data: result.data, + }); + }; export const getSettings = (settingsKey?) => async (dispatch) => { const result = await axios({ diff --git a/src/client/components/AirDCPPSettings/AirDCPPHubsForm.tsx b/src/client/components/AirDCPPSettings/AirDCPPHubsForm.tsx index 9a2bb9e..11841fd 100644 --- a/src/client/components/AirDCPPSettings/AirDCPPHubsForm.tsx +++ b/src/client/components/AirDCPPSettings/AirDCPPHubsForm.tsx @@ -30,7 +30,7 @@ export const AirDCPPHubsForm = (airDCPPClientUserSettings): ReactElement => { const onSubmit = (values) => { if (!isUndefined(values.hubs)) { - dispatch(saveSettings({ hubs: values.hubs }, settings._id)); + dispatch(saveSettings({ ...settings, hubs: values.hubs }, settings._id)); } }; diff --git a/src/client/components/AirDCPPSettings/AirDCPPSettingsForm.tsx b/src/client/components/AirDCPPSettings/AirDCPPSettingsForm.tsx index 627be42..375b1c9 100644 --- a/src/client/components/AirDCPPSettings/AirDCPPSettingsForm.tsx +++ b/src/client/components/AirDCPPSettings/AirDCPPSettingsForm.tsx @@ -26,7 +26,6 @@ export const AirDCPPSettingsForm = (): ReactElement => { dispatch(deleteSettings()); }, []); const validate = async () => {}; - console.log(airDCPPSettings.airDCPPState); const initFormData = !isUndefined( airDCPPSettings.airDCPPState.settings.directConnect, ) diff --git a/src/client/components/App.tsx b/src/client/components/App.tsx index 3ca7575..5aacc81 100644 --- a/src/client/components/App.tsx +++ b/src/client/components/App.tsx @@ -30,7 +30,8 @@ const AirDCPPSocketComponent = (): ReactElement => { const foo = async () => { if ( !isUndefined(airDCPPConfiguration.airDCPPState) && - !isEmpty(airDCPPConfiguration.airDCPPState.settings) + !isEmpty(airDCPPConfiguration.airDCPPState.settings) && + !isEmpty(airDCPPConfiguration.airDCPPState.socket) ) { await airDCPPConfiguration.airDCPPState.socket.addListener( "queue", diff --git a/src/client/components/ComicDetail/DownloadsPanel.tsx b/src/client/components/ComicDetail/DownloadsPanel.tsx index 291c707..9282364 100644 --- a/src/client/components/ComicDetail/DownloadsPanel.tsx +++ b/src/client/components/ComicDetail/DownloadsPanel.tsx @@ -25,7 +25,11 @@ export const DownloadsPanel = ( // AirDCPP Socket initialization const userSettings = useSelector((state: RootState) => state.settings.data); - const { ADCPPSocket } = useContext(AirDCPPSocketContext); + const airDCPPConfiguration = useContext(AirDCPPSocketContext); + + const { + airDCPPState: { socket, settings }, + } = airDCPPConfiguration; const dispatch = useDispatch(); // Fetch the downloaded files and currently-downloading file(s) from AirDC++ @@ -33,16 +37,16 @@ export const DownloadsPanel = ( try { if (!isEmpty(userSettings)) { dispatch( - getBundlesForComic(props.comicObjectId, ADCPPSocket, { - username: `${userSettings.directConnect.client.host.username}`, - password: `${userSettings.directConnect.client.host.password}`, + getBundlesForComic(props.comicObjectId, socket, { + username: `${settings.directConnect.client.host.username}`, + password: `${settings.directConnect.client.host.password}`, }), ); } } catch (error) { throw new Error(error); } - }, [dispatch]); + }, [dispatch, airDCPPConfiguration]); const Bundles = (props) => { return !isEmpty(props.data) ? ( @@ -81,7 +85,7 @@ export const DownloadsPanel = ( return !isNil(props.data) ? ( <>