Skip to content

Commit 8fdccbb

Browse files
committed
address review
1 parent 9c19230 commit 8fdccbb

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/components/Videos_List.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ function createUploadProgressState(files) {
212212
return {
213213
fileSizes,
214214
loadedByFile: fileSizes.map(() => 0),
215+
loadedBytes: 0,
215216
totalBytes: fileSizes.reduce((sum, size) => sum + size, 0)
216217
}
217218
}
@@ -224,9 +225,11 @@ function setAggregateUploadProgress(state, index, loadedBytes) {
224225
}
225226
226227
const fileSize = state.fileSizes[index]
227-
state.loadedByFile[index] = Math.min(fileSize, Math.max(0, loadedBytes))
228-
const loadedTotal = state.loadedByFile.reduce((sum, loaded) => sum + loaded, 0)
229-
const nextPercent = Math.min(100, Math.max(0, Math.round((loadedTotal / state.totalBytes) * 100)))
228+
const previousLoadedBytes = state.loadedByFile[index]
229+
const nextLoadedBytes = Math.min(fileSize, Math.max(0, loadedBytes))
230+
state.loadedByFile[index] = nextLoadedBytes
231+
state.loadedBytes += nextLoadedBytes - previousLoadedBytes
232+
const nextPercent = Math.min(100, Math.max(0, Math.round((state.loadedBytes / state.totalBytes) * 100)))
230233
231234
uploadProgressPercent.value = nextPercent
232235
uploadPhase.value = nextPercent >= 100 ? 'processing' : 'uploading'

0 commit comments

Comments
 (0)