Refine progress calculation for more granular updates (#827)

This commit is contained in:
Montassar Ghanmy
2025-02-27 10:45:03 +01:00
committed by GitHub
parent 21d70fdb02
commit 39a062b942
@@ -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