From 34113c369842031922c11f1349a2e940334a3e43 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sun, 2 Jul 2023 10:12:31 +0200 Subject: [PATCH] fix progress bar when uploading --- interface/src/components/upload/SingleUpload.tsx | 11 ++++++----- interface/src/framework/system/UploadFileForm.tsx | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/src/components/upload/SingleUpload.tsx b/interface/src/components/upload/SingleUpload.tsx index 8c5358706..498e4b913 100644 --- a/interface/src/components/upload/SingleUpload.tsx +++ b/interface/src/components/upload/SingleUpload.tsx @@ -26,11 +26,12 @@ const getBorderColor = (theme: Theme, props: DropzoneState) => { export interface SingleUploadProps { onDrop: (acceptedFiles: File[]) => void; onCancel: () => void; + isUploading: boolean; progress: Progress; } -const SingleUpload: FC = ({ onDrop, onCancel, progress }) => { - const isUploading = progress.total > 0; +const SingleUpload: FC = ({ onDrop, onCancel, isUploading, progress }) => { + const uploading = isUploading && progress.total > 0; const dropzoneState = useDropzone({ onDrop, @@ -48,7 +49,7 @@ const SingleUpload: FC = ({ onDrop, onCancel, progress }) => const { LL } = useI18nContext(); const progressText = () => { - if (isUploading) { + if (uploading) { if (progress.total) { return LL.UPLOADING() + ': ' + Math.round((progress.loaded * 100) / progress.total) + '%'; } @@ -68,7 +69,7 @@ const SingleUpload: FC = ({ onDrop, onCancel, progress }) => color: theme.palette.grey[400], transition: 'border .24s ease-in-out', width: '100%', - cursor: isUploading ? 'default' : 'pointer', + cursor: uploading ? 'default' : 'pointer', borderColor: getBorderColor(theme, dropzoneState) } })} @@ -77,7 +78,7 @@ const SingleUpload: FC = ({ onDrop, onCancel, progress }) => {progressText()} - {isUploading && ( + {uploading && ( { setMd5(data.md5); toast.success(LL.UPLOAD() + ' MD5 ' + LL.SUCCESSFUL()); } else { - toast.success(LL.UPLOAD() + ' ' + LL.SUCCESSFUL()); setRestarting(true); } }); @@ -123,7 +122,7 @@ const UploadFileForm: FC = () => { {'MD5: ' + md5} )} - + {!isUploading && ( <>