Browse Source

remove `uploader` from `upload-progress` event (#5200)

Mikael Finstad 10 months ago
parent
commit
71b4f0c8f7

+ 3 - 3
packages/@uppy/aws-s3/src/index.ts

@@ -767,9 +767,9 @@ export default class AwsS3Multipart<
   #uploadLocalFile(file: UppyFile<M, B>) {
     return new Promise<void | string>((resolve, reject) => {
       const onProgress = (bytesUploaded: number, bytesTotal: number) => {
-        this.uppy.emit('upload-progress', this.uppy.getFile(file.id), {
-          // @ts-expect-error TODO: figure out if we need this
-          uploader: this,
+        const latestFile = this.uppy.getFile(file.id)
+        this.uppy.emit('upload-progress', latestFile, {
+          uploadStarted: latestFile.progress.uploadStarted ?? 0,
           bytesUploaded,
           bytesTotal,
         })

+ 3 - 4
packages/@uppy/tus/src/index.ts

@@ -315,10 +315,9 @@ export default class Tus<M extends Meta, B extends Body> extends BasePlugin<
         if (typeof opts.onProgress === 'function') {
           opts.onProgress(bytesUploaded, bytesTotal)
         }
-        this.uppy.emit('upload-progress', this.uppy.getFile(file.id), {
-          // TODO: remove `uploader` in next major
-          // @ts-expect-error untyped
-          uploader: this,
+        const latestFile = this.uppy.getFile(file.id)
+        this.uppy.emit('upload-progress', latestFile, {
+          uploadStarted: latestFile.progress.uploadStarted ?? 0,
           bytesUploaded,
           bytesTotal,
         })

+ 1 - 2
packages/@uppy/utils/src/emitSocketProgress.ts

@@ -15,8 +15,7 @@ function emitSocketProgress(
   if (progress) {
     uploader.uppy.log(`Upload progress: ${progress}`)
     uploader.uppy.emit('upload-progress', file, {
-      // @ts-expect-error todo remove in next major
-      uploader,
+      uploadStarted: file.progress.uploadStarted ?? 0,
       bytesUploaded,
       bytesTotal,
     } satisfies FileProgress)

+ 1 - 3
packages/@uppy/xhr-upload/src/index.ts

@@ -197,9 +197,7 @@ export default class XHRUpload<
               if (event.lengthComputable) {
                 for (const file of files) {
                   this.uppy.emit('upload-progress', file, {
-                    // TODO: do not send `uploader` in next major
-                    // @ts-expect-error we can't type this and we should remove it
-                    uploader: this,
+                    uploadStarted: file.progress.uploadStarted ?? 0,
                     bytesUploaded: (event.loaded / event.total) * file.size!,
                     bytesTotal: file.size,
                   })