Skip to content

Commit

Permalink
✨ Refine progress calculation for more granular updates (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
MontaGhanmy authored Feb 27, 2025
1 parent 21d70fd commit 39a062b
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,17 @@ class FileUploadService {
const updatedState = Object.keys(this.groupedPendingFiles).reduce((acc: any, key: string) => {
// Calculate the uploaded size
const uploadedSize = this.groupedPendingFiles[key]
.map((f: PendingFileType) =>
f.status === 'success' && f.originalFile?.size ? f.originalFile.size : 0,
)
.map((file: PendingFileType) => {
const fileSize = file.originalFile?.size ?? 0;

if (file.status === 'success') {
return fileSize;
} else if (file.status === 'pending') {
return fileSize * (file.progress ?? 0); // Ensure progress is defined
}

return 0;
})
.reduce((acc: number, size: number) => acc + size, 0);

// Check for failed files
Expand Down

0 comments on commit 39a062b

Please sign in to comment.