Skip to content

Commit

Permalink
workaround for emsesp#1564
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Jan 20, 2024
1 parent d5cb5c1 commit 65ff765
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions interface/src/components/upload/SingleUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ const SingleUpload: FC<SingleUploadProps> = ({ onDrop, onCancel, isUploading, pr

const progressText = () => {
if (uploading) {
if (progress.total) {
return LL.UPLOADING() + ': ' + Math.round((progress.loaded * 100) / progress.total) + '%';
if (progress.total && progress.loaded) {
return progress.loaded <= progress.total
? LL.UPLOADING() + ': ' + Math.round((progress.loaded * 100) / progress.total) + '%'
: LL.UPLOADING() + ': ' + Math.round((progress.total * 100) / progress.loaded) + '%';
}
}
return LL.UPLOAD_DROP_TEXT();
Expand Down Expand Up @@ -83,7 +85,13 @@ const SingleUpload: FC<SingleUploadProps> = ({ onDrop, onCancel, isUploading, pr
<Box width="100%" p={2}>
<LinearProgress
variant="determinate"
value={progress.total === 0 ? 0 : Math.round((progress.loaded * 100) / progress.total)}
value={
progress.total === 0 || progress.loaded === 0
? 0
: progress.loaded <= progress.total
? Math.round((progress.loaded * 100) / progress.total)
: Math.round((progress.total * 100) / progress.loaded)
}
/>
</Box>
<Button startIcon={<CancelIcon />} variant="outlined" color="secondary" onClick={onCancel}>
Expand Down

0 comments on commit 65ff765

Please sign in to comment.