Settings.
- diff --git a/src/client/components/ComicDetail/AcquisitionPanel.tsx b/src/client/components/ComicDetail/AcquisitionPanel.tsx index 3e1f7f5..3b1801e 100644 --- a/src/client/components/ComicDetail/AcquisitionPanel.tsx +++ b/src/client/components/ComicDetail/AcquisitionPanel.tsx @@ -16,6 +16,7 @@ import { Form, Field } from "react-final-form"; import { isEmpty, isNil, map } from "lodash"; import { useStore } from "../../store"; import { useShallow } from "zustand/react/shallow"; +import { useQuery } from "@tanstack/react-query"; interface IAcquisitionPanelProps { query: any; @@ -38,7 +39,16 @@ export const AcquisitionPanel = ( airDCPPSessionInformation: state.airDCPPSessionInformation, })), ); - console.log("ulhas umlaut", airDCPPSessionInformation); + + /** + * Get the hubs list from an AirDCPP Socket + */ + const { data: hubs } = useQuery({ + queryKey: ["hubs"], + queryFn: async () => await airDCPPSocketInstance.get(`hubs`), + }); + + console.log("narangi umlaut", hubs); const issueName = props.query.issue.name || ""; // const { settings } = props; const sanitizedIssueName = issueName.replace(/[^a-zA-Z0-9 ]/g, " "); @@ -66,45 +76,34 @@ export const AcquisitionPanel = ( // Pre-populate the search input with the search string, so that // All the user has to do is hit "Search AirDC++" useEffect(() => { - // if (!isEmpty(airDCPPConfiguration.airDCPPState.settings)) { - // // AirDC++ search query - // const dcppSearchQuery = { - // query: { - // pattern: `${sanitizedIssueName.replace(/#/g, "")}`, - // extensions: ["cbz", "cbr", "cb7"], - // }, - // hub_urls: map( - // airDCPPConfiguration.airDCPPState.settings.directConnect.client.hubs, - // (item) => item.value, - // ), - // priority: 5, - // }; - // setDcppQuery(dcppSearchQuery); - // } - }, [airDCPPConfiguration]); + // AirDC++ search query + const dcppSearchQuery = { + query: { + pattern: `${sanitizedIssueName.replace(/#/g, "")}`, + extensions: ["cbz", "cbr", "cb7"], + }, + hub_urls: map(hubs, (item) => item.value), + priority: 5, + }; + setDcppQuery(dcppSearchQuery); + }, []); - const getDCPPSearchResults = useCallback( - async (searchQuery) => { - const manualQuery = { - query: { - pattern: `${searchQuery.issueName}`, - extensions: ["cbz", "cbr", "cb7"], - }, - hub_urls: map( - airDCPPConfiguration.airDCPPState.settings.directConnect.client.hubs, - (item) => item.value, - ), - priority: 5, - }; - // dispatch( - // search(manualQuery, airDCPPConfiguration.airDCPPState.socket, { - // username: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.username}`, - // password: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.password}`, - // }), - // ); - }, - [airDCPPConfiguration], - ); + const getDCPPSearchResults = useCallback(async (searchQuery) => { + const manualQuery = { + query: { + pattern: `${searchQuery.issueName}`, + extensions: ["cbz", "cbr", "cb7"], + }, + hub_urls: map(hubs, (item) => item.value), + priority: 5, + }; + // dispatch( + // search(manualQuery, airDCPPConfiguration.airDCPPState.socket, { + // username: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.username}`, + // password: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.password}`, + // }), + // ); + }, []); // download via AirDC++ const downloadDCPPResult = useCallback( @@ -136,218 +135,9 @@ export const AcquisitionPanel = ( // ), // ); }, - [airDCPPConfiguration], - ); - return ( - <> -
Settings.
- | Name | -Type | -Slots | -Actions | -
|---|---|---|---|
|
- - {result.type.id === "directory" ? ( - - ) : null}{" "} - {ellipsize(result.name, 70)} - - -
|
- - - {result.type.id === "directory" - ? "directory" - : result.type.str} - - | -
-
-
- {result.slots.free} free
-
-
- {result.slots.total}
-
-
- |
- - - downloadDCPPResult( - searchInstance.id, - result.id, - result.name, - result.size, - result.type, - ) - } - > - - - | -
ADCS hubs are
- more reliable than NMDCS ones.
-