🔧 Refactoring
This commit is contained in:
@@ -15,10 +15,10 @@ import {
|
|||||||
AIRDCPP_BUNDLES_FETCHED,
|
AIRDCPP_BUNDLES_FETCHED,
|
||||||
AIRDCPP_SEARCH_IN_PROGRESS,
|
AIRDCPP_SEARCH_IN_PROGRESS,
|
||||||
AIRDCPP_FILE_DOWNLOAD_COMPLETED,
|
AIRDCPP_FILE_DOWNLOAD_COMPLETED,
|
||||||
|
LS_SINGLE_IMPORT,
|
||||||
IMS_COMIC_BOOK_DB_OBJECT_FETCHED,
|
IMS_COMIC_BOOK_DB_OBJECT_FETCHED,
|
||||||
} from "../constants/action-types";
|
} from "../constants/action-types";
|
||||||
import { difference } from "../shared/utils/object.utils";
|
import { isNil, isUndefined } from "lodash";
|
||||||
import { isNil, isEmpty, isUndefined } from "lodash";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
interface SearchData {
|
interface SearchData {
|
||||||
@@ -133,6 +133,19 @@ 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;
|
||||||
|
// 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 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let bundleId;
|
let bundleId;
|
||||||
let directoryIds;
|
let directoryIds;
|
||||||
@@ -197,17 +210,6 @@ export const getDownloadProgress =
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let downloadStatus = undefined;
|
|
||||||
// download status check
|
|
||||||
await ADCPPSocket.addListener(`queue`, "queue_file_status", (status) => {
|
|
||||||
if (isUndefined(downloadStatus)) {
|
|
||||||
downloadStatus = status;
|
|
||||||
dispatch({
|
|
||||||
type: AIRDCPP_FILE_DOWNLOAD_COMPLETED,
|
|
||||||
status,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ export const AIRDCPP_RESULT_DOWNLOAD_INITIATED =
|
|||||||
"AIRDCPP_RESULT_DOWNLOAD_INITIATED";
|
"AIRDCPP_RESULT_DOWNLOAD_INITIATED";
|
||||||
export const AIRDCPP_FILE_DOWNLOAD_COMPLETED =
|
export const AIRDCPP_FILE_DOWNLOAD_COMPLETED =
|
||||||
"AIRDCPP_FILE_DOWNLOAD_COMPLETED";
|
"AIRDCPP_FILE_DOWNLOAD_COMPLETED";
|
||||||
|
export const LS_SINGLE_IMPORT = "LS_SINGLE_IMPORT";
|
||||||
export const AIRDCPP_BUNDLES_FETCHED = "AIRDCPP_BUNDLES_FETCHED";
|
export const AIRDCPP_BUNDLES_FETCHED = "AIRDCPP_BUNDLES_FETCHED";
|
||||||
export const AIRDCPP_DOWNLOAD_PROGRESS_TICK = "AIRDCPP_DOWNLOAD_PROGRESS_TICK";
|
export const AIRDCPP_DOWNLOAD_PROGRESS_TICK = "AIRDCPP_DOWNLOAD_PROGRESS_TICK";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user