🔫 Tweaking the trigger for download complete action

This commit is contained in:
2022-05-11 23:40:10 -07:00
parent 30ee5e4a67
commit 6b508d4c36
4 changed files with 23 additions and 19 deletions

View File

@@ -18,7 +18,7 @@ import {
LS_SINGLE_IMPORT,
IMS_COMIC_BOOK_DB_OBJECT_FETCHED,
} from "../constants/action-types";
import { isNil, isUndefined } from "lodash";
import { isNil } from "lodash";
import axios from "axios";
interface SearchData {
@@ -134,16 +134,19 @@ export const downloadAirDCPPItem =
`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;
dispatch({
type: LS_SINGLE_IMPORT,
meta: { remote: true },
data: { downloadStatus, comicObjectId },
});
if (count === 0) {
dispatch({
type: LS_SINGLE_IMPORT,
meta: { remote: true },
data: { downloadStatus, comicObjectId },
});
}
count += 1;
}
});