Skip to content

Commit

Permalink
Use has generated to display beginning of generation
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRobertAnsart committed Sep 3, 2024
1 parent 593f2f1 commit efbcf1b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/pages/create/6-result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const ResultPage = () => {
const { isCollaborationActive } = useCollaboration();
const { socket, connectTeacher } = useSocket();
const [isLoading, setIsLoading] = React.useState(false);
const [hasGenerated, setHasGenerated] = React.useState(false);
const [isGenerating, setIsGenerating] = React.useState(false);
const {
projectVideo,
isLoading: isLoadingProjectVideo,
Expand Down Expand Up @@ -113,8 +113,8 @@ const ResultPage = () => {
}
}, [projectVideo]);

if (isDownloading && !hasGenerated) {
setHasGenerated(true);
if (isDownloading && !isGenerating) {
setIsGenerating(true);
willAutoDownload.current = true;
}

Expand Down Expand Up @@ -168,17 +168,18 @@ const ResultPage = () => {
if (!project || project.id === 0 || !data) {
return;
}
setIsGenerating(true);
createProjectVideoMutation.mutate(
{
projectId: project.id,
data,
},
{
onSuccess: () => {
setHasGenerated(true);
willAutoDownload.current = true;
},
onError: () => {
setIsGenerating(false);
sendToast({ message: t('unknown_error'), type: 'error' });
},
},
Expand Down Expand Up @@ -231,7 +232,7 @@ const ResultPage = () => {
<div>loading</div>
) : (
<>
{createProjectVideoMutation.isLoading || (videoProgress && videoProgress !== 100) ? (
{!videoUrl && isGenerating ? (
<div
style={{
width: '100%',
Expand All @@ -247,9 +248,9 @@ const ResultPage = () => {
<Text className="color-secondary" style={{ fontSize: '0.8rem', marginBottom: '0.5rem' }}>
{t('part6_mp4_loading')}
</Text>
<LinearProgressWithLabel value={videoProgress || 0} />
<LinearProgressWithLabel value={videoProgress === 100 ? 0 : videoProgress ?? 0} />
</div>
) : videoUrl && hasGenerated ? (
) : videoUrl && isGenerating ? (
<Button
label={t('part6_mp4_download_button')}
as="a"
Expand Down

0 comments on commit efbcf1b

Please sign in to comment.