🔄 Moved socket init code higher up into ComicDetail parent component

This commit is contained in:
2021-11-20 02:10:52 -08:00
parent 725c156e88
commit 5251803233
6 changed files with 111 additions and 41 deletions

View File

@@ -33,7 +33,6 @@ export const search =
(data: SearchData, ADCPPSocket: any, credentials: any) =>
async (dispatch) => {
try {
console.log(credentials);
if (!ADCPPSocket.isConnected()) {
await ADCPPSocket.connect(
credentials.username,
@@ -118,11 +117,16 @@ export const downloadAirDCPPItem =
resultId: string,
comicObjectId: string,
ADCPPSocket: any,
credentials: any,
): void =>
async (dispatch) => {
try {
if (!ADCPPSocket.isConnected()) {
await ADCPPSocket.connect("admin", "password", true);
await ADCPPSocket.connect(
`${credentials.username}`,
`${credentials.password}`,
true,
);
}
let bundleDBImportResult = {};
const downloadResult = await ADCPPSocket.post(
@@ -172,11 +176,15 @@ export const downloadAirDCPPItem =
};
export const getDownloadProgress =
(comicObjectId: string, ADCPPSocket: any): void =>
(comicObjectId: string, ADCPPSocket: any, credentials: any): void =>
async (dispatch) => {
try {
if (!ADCPPSocket.isConnected()) {
await ADCPPSocket.connect("admin", "password", true);
await ADCPPSocket.connect(
`${credentials.username}`,
`${credentials.password}`,
true,
);
}
await ADCPPSocket.addListener(
`queue`,
@@ -194,10 +202,15 @@ export const getDownloadProgress =
};
export const getBundlesForComic =
(comicObjectId: string, ADCPPSocket: any) => async (dispatch) => {
(comicObjectId: string, ADCPPSocket: any, credentials: any) =>
async (dispatch) => {
try {
if (!ADCPPSocket.isConnected()) {
await ADCPPSocket.connect("admin", "password", true);
await ADCPPSocket.connect(
`${credentials.username}`,
`${credentials.password}`,
true,
);
}
const comicObject = await axios({
method: "POST",