Skip to content

Commit

Permalink
#495 bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AFPMedialab committed May 17, 2024
1 parent 9bb26b3 commit 6d567cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/components/NavItems/tools/Deepfake/DeepfakeImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const Deepfake = () => {

const submitUrl = () => {
UseGetDeepfake(
keyword,
input,
true,
selectedMode,
Expand Down
1 change: 1 addition & 0 deletions src/components/NavItems/tools/Deepfake/DeepfakeVideo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const Deepfake = () => {

const submitUrl = () => {
UseGetDeepfake(
keyword,
input,
true,
selectedMode,
Expand Down
13 changes: 7 additions & 6 deletions src/components/NavItems/tools/Deepfake/Hooks/useGetDeepfake.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { setError } from "redux/reducers/errorReducer";
import { isValidUrl } from "../../../../Shared/Utils/URLUtils";

async function UseGetDeepfake(
keyword,
url,
processURL,
mode,
Expand Down Expand Up @@ -48,7 +49,7 @@ async function UseGetDeepfake(
let res;

const handleError = (e) => {
dispatch(setError(e));
dispatch(setError(keyword(e)));
if (mode === "IMAGE") {
dispatch(setDeepfakeLoadingImage(false));
} else if (mode === "VIDEO") {
Expand Down Expand Up @@ -82,15 +83,15 @@ async function UseGetDeepfake(
break;
}
} catch (error) {
handleError("error_" + error.status);
handleError("deepfake_error_" + error.response.status);
}

const getResult = async (id) => {
let response;
try {
response = await axios.get(baseURL + modeURL + "reports/" + id);
} catch (error) {
handleError("error_" + error.status);
handleError("deepfake_error_" + error.status);
}

if (response.data != null) {
Expand All @@ -115,7 +116,7 @@ async function UseGetDeepfake(
try {
response = await axios.get(baseURL + modeURL + "jobs/" + id);
} catch (error) {
handleError("error_" + error.status);
handleError("deepfake_error_" + error.status);
}

if (response && response.data && response.data.status === "PROCESSING") {
Expand All @@ -127,11 +128,11 @@ async function UseGetDeepfake(
) {
await getResult(id);
} else {
handleError("error_" + response.data.status);
handleError("deepfake_error_" + response.data.status);
}
};

waitUntilFinish(res.data.id);
res ? waitUntilFinish(res.data.id) : null;
}

function sleep(fn, param) {
Expand Down

0 comments on commit 6d567cb

Please sign in to comment.