Bläddra i källkod

@uppy/status-bar: fix ETA when status bar is installed during upload (#4588)

* @uppy/status-bar: fix ETA when status bar is installed during upload

* Apply suggestions from code review
Antoine du Hamel 1 år sedan
förälder
incheckning
49cf48d541
1 ändrade filer med 6 tillägg och 0 borttagningar
  1. 6 0
      packages/@uppy/status-bar/src/StatusBar.jsx

+ 6 - 0
packages/@uppy/status-bar/src/StatusBar.jsx

@@ -254,6 +254,12 @@ export default class StatusBar extends UIPlugin {
       this.mount(target, this)
     }
     this.uppy.on('upload', this.#onUploadStart)
+
+    // To cover the use case where the status bar is installed while the upload
+    // has started, we set `lastUpdateTime` right away.
+    this.#lastUpdateTime = performance.now()
+    this.#previousUploadedBytes = this.uppy.getFiles()
+      .reduce((pv, file) => pv + file.progress.bytesUploaded, 0)
   }
 
   uninstall () {