Skip to content

Commit

Permalink
fix download image button
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed Hussein committed Sep 1, 2024
1 parent e6b1236 commit 143e640
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type Props = {
isFetching: boolean;
};

// TODO: create a common component with RenderVideoButton since most of the component contains the same code.
const RenderImageButton: React.FC<Props> = ({
inputProps,
getCurrentFrame,
Expand All @@ -46,13 +45,13 @@ const RenderImageButton: React.FC<Props> = ({
const isRendering = state.status === RenderStatus.RENDERING;
const isInvoking = state.status === RenderStatus.INVOKING;
const isDone = state.status === RenderStatus.DONE;

const isInitOrInvokingOrError = [
RenderStatus.INVOKING,
RenderStatus.INIT,
RenderStatus.ERROR,
].includes(state.status);
const isRenderingOrDone = [RenderStatus.RENDERING, RenderStatus.DONE].includes(state.status);
const isError = state?.status === RenderStatus.ERROR;

const onRenderOrDownloadClicked = (e: React.MouseEvent<HTMLParagraphElement>) => {
if (isInitOrInvokingOrError) {
Expand All @@ -76,13 +75,10 @@ const RenderImageButton: React.FC<Props> = ({
}
};

const isError = state?.status === RenderStatus.ERROR;

// listen to state changes and download the file when it's done
useEffect(() => {
if (state?.status === RenderStatus.DONE) {
downloadButtonRef.current.click();
previousFrame.current = getCurrentFrame();
mutate(mutateGeneratedMediaCounter, { revalidate: false });
}
}, [getCurrentFrame, mutate, state?.status]);
Expand Down

0 comments on commit 143e640

Please sign in to comment.