⤵️ Downloads page scaffold

This commit is contained in:
2022-07-10 21:11:56 -07:00
parent 23a0d2c231
commit f865feeeb2
4 changed files with 183 additions and 176 deletions

View File

@@ -1,4 +1,3 @@
import SocketService from "../services/DcppSearchService";
import { import {
SearchQuery, SearchQuery,
SearchInstance, SearchInstance,
@@ -136,22 +135,7 @@ export const downloadAirDCPPItem =
const downloadResult = await ADCPPSocket.post( const downloadResult = await ADCPPSocket.post(
`search/${instanceId}/results/${resultId}/download`, `search/${instanceId}/results/${resultId}/download`,
); );
let downloadStatus = undefined;
let count = 0;
// download status check
await ADCPPSocket.addListener(`queue`, "queue_file_status", (status) => {
if (status.status.completed) {
downloadStatus = status;
if (count === 0) {
dispatch({
type: LS_SINGLE_IMPORT,
meta: { remote: true },
data: { downloadStatus, comicObjectId, comicObject },
});
}
count += 1;
}
});
let bundleId; let bundleId;
let directoryIds; let directoryIds;
@@ -242,10 +226,20 @@ export const getTransfers =
} }
const bundles = await ADCPPSocket.get("queue/bundles/1/50", {}); const bundles = await ADCPPSocket.get("queue/bundles/1/50", {});
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);
console.log(bundleIds);
// get issues with matching bundleIds
const issues = await axios({
url: `${LIBRARY_SERVICE_BASE_URI}/groupIssuesByBundles`,
method: "POST",
data: bundleIds,
});
} }
} catch (err) { } catch (err) {
throw err; throw err;

View File

@@ -51,12 +51,23 @@ const AirDCPPSocketComponent = (): ReactElement => {
}); });
}, },
); );
// download complete listener
await airDCPPConfiguration.airDCPPState.socket.addListener(
`transfers`,
"transfer_completed",
async (transferData) => {
console.log(transferData)
},
);
console.log( console.log(
"[AirDCPP]: Listener registered - listening to queue bundle download ticks", "[AirDCPP]: Listener registered - listening to queue bundle download ticks",
); );
console.log( console.log(
"[AirDCPP]: Listener registered - listening to queue bundle changes", "[AirDCPP]: Listener registered - listening to queue bundle changes",
); );
console.log(
"[AirDCPP]: Listener registered - listening to transfer completion",
);
} }
}; };
foo(); foo();

View File

@@ -16,7 +16,7 @@ export const Downloads = (props: IDownloadsProps): ReactElement => {
} = airDCPPConfiguration; } = airDCPPConfiguration;
const dispatch = useDispatch(); const dispatch = useDispatch();
const AirDCPPTransfers = useSelector( const airDCPPTransfers = useSelector(
(state: RootState) => state.airdcpp.transfers, (state: RootState) => state.airdcpp.transfers,
); );
useEffect(() => { useEffect(() => {
@@ -46,8 +46,10 @@ export const Downloads = (props: IDownloadsProps): ReactElement => {
); );
} }
}, [socket]); }, [socket]);
// const getAllDownloads = useCallback(() => {}); // const getAllDownloads = useCallback(() => {});
return <pre>{JSON.stringify(AirDCPPTransfers, null, 2)}</pre>; return <pre>{JSON.stringify(airDCPPTransfers, null, 2)}</pre>;
}; };
export default Downloads; export default Downloads;

View File

@@ -16,8 +16,8 @@ export default {
//👇 We create a “template” of how args map to rendering //👇 We create a “template” of how args map to rendering
const Template = (args) => <MetadataPanel {...args} />; const Template = (args) => <MetadataPanel {...args} />;
//👇 Each story then reuses that template //👇 Each story then reuses that template
export const ComicVine = Template.bind({}); export const RawFileDetails = Template.bind({});
ComicVine.args = { RawFileDetails.args = {
data: { data: {
"_id": { "$oid": "62bb40c82089f1ea67997e0d" }, "_id": { "$oid": "62bb40c82089f1ea67997e0d" },
"__v": 0, "__v": 0,