Skip to content

Commit

Permalink
Merge pull request #609 from AFP-Medialab/fix-606
Browse files Browse the repository at this point in the history
Fixes #606
  • Loading branch information
Sallaa authored Oct 1, 2024
2 parents 47af761 + 2c9b741 commit 28f716e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
9 changes: 5 additions & 4 deletions src/components/NavItems/tools/Deepfake/DeepfakeVideo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const Deepfake = () => {

const dispatch = useDispatch();

const submitUrl = () => {
UseGetDeepfake(
const submitUrl = async () => {
await UseGetDeepfake(
keyword,
input,
true,
Expand Down Expand Up @@ -78,9 +78,9 @@ const Deepfake = () => {
preprocessingError,
);
};
const handleSubmit = () => {
const handleSubmit = async () => {
dispatch(resetDeepfake());
submitUrl();
await submitUrl();
};

const handleClose = () => {
Expand Down Expand Up @@ -139,6 +139,7 @@ const Deepfake = () => {
fileInputTypesAccepted={"video/*"}
handleCloseSelectedFile={handleClose}
preprocessLocalFile={preprocessVideo}
isParentLoading={isLoading}
/>
</form>
<Box m={2} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const DeepfakeResultsVideo = (props) => {
alignItems="flex-start"
>
<Grid2 size={{ xs: 6 }} container direction="column" spacing={3}>
<Grid2 size={{ xs: 6 }} container direction="column">
<Grid2 width="100%" size={{ xs: 6 }} container direction="column">
<video
width="100%"
height="auto"
Expand All @@ -219,7 +219,7 @@ const DeepfakeResultsVideo = (props) => {
</video>
</Grid2>
{!!results.deepfake_video_report.results && (
<Grid2 size={{ xs: 6 }} container direction="column">
<Grid2 size={{ xs: 6 }} container width="100%" direction="column">
<Typography
variant="body1"
style={{
Expand Down
25 changes: 8 additions & 17 deletions src/components/Shared/StringFileUploadField/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from "react";
import React, { useRef } from "react";
import Box from "@mui/material/Box";
import { Button, ButtonGroup, Grid2, TextField } from "@mui/material";
import FolderOpenIcon from "@mui/icons-material/FolderOpen";
Expand Down Expand Up @@ -41,16 +41,6 @@ const StringFileUploadField = ({
}) => {
const fileRef = useRef(null);

const [isLoading, setIsLoading] = useState(
isParentLoading !== undefined ? isParentLoading : false,
);

useEffect(() => {
if (isParentLoading !== undefined && isLoading !== isParentLoading) {
setIsLoading(isParentLoading);
}
}, [isParentLoading]);

return (
<Box>
<Grid2 container direction="row" spacing={3} alignItems="center">
Expand All @@ -63,7 +53,7 @@ const StringFileUploadField = ({
fullWidth
value={urlInput}
variant="outlined"
disabled={isLoading || fileInput instanceof Blob}
disabled={isParentLoading || fileInput instanceof Blob}
onChange={(e) => setUrlInput(e.target.value)}
/>
</Grid2>
Expand All @@ -74,19 +64,20 @@ const StringFileUploadField = ({
color="primary"
onClick={async (e) => {
e.preventDefault();
setIsLoading(true);
urlInput ? await handleSubmit(urlInput) : await handleSubmit(e);
setIsLoading(false);
}}
loading={isLoading}
disabled={(urlInput === "" && !fileInput) || isLoading}
loading={isParentLoading}
disabled={(urlInput === "" && !fileInput) || isParentLoading}
>
{submitButtonKeyword}
</LoadingButton>
</Grid2>
</Grid2>
<Grid2 mt={2}>
<ButtonGroup variant="outlined" disabled={isLoading || urlInput !== ""}>
<ButtonGroup
variant="outlined"
disabled={isParentLoading || urlInput !== ""}
>
<Button startIcon={<FolderOpenIcon />} sx={{ textTransform: "none" }}>
<label htmlFor="file">
{fileInput ? fileInput.name : localFileKeyword}
Expand Down

0 comments on commit 28f716e

Please sign in to comment.