🔎 Integration with DC++ downloads endpoint

This commit is contained in:
2022-07-24 22:20:25 -07:00
parent f865feeeb2
commit 365fa2e115
5 changed files with 24 additions and 22 deletions

View File

@@ -4,7 +4,7 @@ import {
PriorityEnum, PriorityEnum,
SearchResponse, SearchResponse,
} from "threetwo-ui-typings"; } from "threetwo-ui-typings";
import { LIBRARY_SERVICE_BASE_URI } from "../constants/endpoints"; import { LIBRARY_SERVICE_BASE_URI, SEARCH_SERVICE_BASE_URI } from "../constants/endpoints";
import { import {
AIRDCPP_SEARCH_RESULTS_ADDED, AIRDCPP_SEARCH_RESULTS_ADDED,
AIRDCPP_SEARCH_RESULTS_UPDATED, AIRDCPP_SEARCH_RESULTS_UPDATED,
@@ -130,7 +130,6 @@ export const downloadAirDCPPItem =
true, true,
); );
} }
console.log(comicObject);
let bundleDBImportResult = {}; let bundleDBImportResult = {};
const downloadResult = await ADCPPSocket.post( const downloadResult = await ADCPPSocket.post(
`search/${instanceId}/results/${resultId}/download`, `search/${instanceId}/results/${resultId}/download`,
@@ -200,15 +199,17 @@ export const getBundlesForComic =
}, },
}); });
// get only the bundles applicable for the comic // get only the bundles applicable for the comic
const filteredBundles = comicObject.data.acquisition.directconnect.map( if (comicObject.data.acquisition.directconnect) {
async ({ bundleId }) => { const filteredBundles = comicObject.data.acquisition.directconnect.downloads.map(
return await ADCPPSocket.get(`queue/bundles/${bundleId}`); async ({ bundleId }) => {
}, return await ADCPPSocket.get(`queue/bundles/${bundleId}`);
); },
dispatch({ );
type: AIRDCPP_BUNDLES_FETCHED, dispatch({
bundles: await Promise.all(filteredBundles), type: AIRDCPP_BUNDLES_FETCHED,
}); bundles: await Promise.all(filteredBundles),
});
}
} catch (error) { } catch (error) {
throw error; throw error;
} }
@@ -224,20 +225,18 @@ export const getTransfers =
true, true,
); );
} }
const bundles = await ADCPPSocket.get("queue/bundles/1/50", {}); const bundles = await ADCPPSocket.get("queue/bundles/1/85", {});
if (!isNil(bundles)) { if (!isNil(bundles)) {
dispatch({ dispatch({
type: AIRDCPP_TRANSFERS_FETCHED, type: AIRDCPP_TRANSFERS_FETCHED,
bundles, bundles,
}); });
const bundleIds = bundles.map((bundle) => bundle.id); const bundleIds = bundles.map((bundle) => bundle.id);
console.log(bundleIds);
// get issues with matching bundleIds // get issues with matching bundleIds
const issues = await axios({ const issues = await axios({
url: `${LIBRARY_SERVICE_BASE_URI}/groupIssuesByBundles`, url: `${SEARCH_SERVICE_BASE_URI}/groupIssuesByBundles`,
method: "POST", method: "POST",
data: bundleIds, data: { bundleIds },
}); });
} }

View File

@@ -119,7 +119,7 @@ export const AcquisitionPanel = (
), ),
); );
}, },
[], [airDCPPConfiguration],
); );
return ( return (
<> <>

View File

@@ -57,6 +57,7 @@ export const DownloadsPanel = (
<th>Filename</th> <th>Filename</th>
<th>Size</th> <th>Size</th>
<th>Download Time</th> <th>Download Time</th>
<th>Bundle ID</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -72,6 +73,9 @@ export const DownloadsPanel = (
.unix(bundle.time_finished) .unix(bundle.time_finished)
.format("h:mm on ddd, D MMM, YYYY")} .format("h:mm on ddd, D MMM, YYYY")}
</td> </td>
<td>
<span className="tag is-warning">{bundle.id}</span>
</td>
</tr> </tr>
))} ))}
</tbody> </tbody>

View File

@@ -10,7 +10,7 @@ export const TabControls = (props): ReactElement => {
const [active, setActive] = useState(filteredTabs[0].id); const [active, setActive] = useState(filteredTabs[0].id);
useEffect(() => { useEffect(() => {
console.log("changed"); console.log(comicBookDetailData);
setActive(filteredTabs[0].id); setActive(filteredTabs[0].id);
}, [comicBookDetailData]); }, [comicBookDetailData]);
@@ -27,12 +27,11 @@ export const TabControls = (props): ReactElement => {
{/* Downloads tab and count badge */} {/* Downloads tab and count badge */}
<a> <a>
{id === 5 && {id === 5 &&
!isNil(comicBookDetailData) && !isNil(comicBookDetailData.acquisition.directconnect) ? (
!isEmpty(comicBookDetailData) ? (
<span className="download-icon-labels"> <span className="download-icon-labels">
<i className="fa-solid fa-download"></i> <i className="fa-solid fa-download"></i>
<span className="tag downloads-count is-info is-light"> <span className="tag downloads-count is-info is-light">
{comicBookDetailData.acquisition.directconnect.length} {comicBookDetailData.acquisition.directconnect.downloads.length}
</span> </span>
</span> </span>
) : ( ) : (

View File

@@ -20,7 +20,7 @@ export const PullList = ({ issues }: PullListProps): ReactElement => {
useEffect(() => { useEffect(() => {
dispatch( dispatch(
getWeeklyPullList({ getWeeklyPullList({
startDate: "2022-7-7", startDate: "2022-7-29",
pageSize: "15", pageSize: "15",
currentPage: "1", currentPage: "1",
}), }),