浏览代码

core: use `uploadStarted: null` instead of false (#1628)

* core: use `uploadStarted: null` instead of false

Fixes #1615

* Update jest snapshots
Renée Kooi 5 年之前
父节点
当前提交
a508cf7c44

+ 2 - 2
packages/@uppy/core/src/__snapshots__/index.test.js.snap

@@ -31,7 +31,7 @@ Object {
         "bytesUploaded": 0,
         "percentage": 0,
         "uploadComplete": false,
-        "uploadStarted": false,
+        "uploadStarted": null,
       },
       "remote": "",
       "size": null,
@@ -54,7 +54,7 @@ Object {
         "bytesUploaded": 0,
         "percentage": 0,
         "uploadComplete": false,
-        "uploadStarted": false,
+        "uploadStarted": null,
       },
       "remote": "",
       "size": null,

+ 2 - 2
packages/@uppy/core/src/index.js

@@ -221,7 +221,7 @@ class Uppy {
       percentage: 0,
       bytesUploaded: 0,
       uploadComplete: false,
-      uploadStarted: false
+      uploadStarted: null
     }
     const files = Object.assign({}, this.getState().files)
     const updatedFiles = {}
@@ -450,7 +450,7 @@ class Uppy {
         bytesUploaded: 0,
         bytesTotal: size,
         uploadComplete: false,
-        uploadStarted: false
+        uploadStarted: null
       },
       size: size,
       isRemote: isRemote,

+ 9 - 9
packages/@uppy/core/src/index.test.js

@@ -412,7 +412,7 @@ describe('src/Core', () => {
         bytesUploaded: 0,
         bytesTotal: 17175,
         uploadComplete: false,
-        uploadStarted: false,
+        uploadStarted: null,
         preprocess: { mode: 'determinate', message: 'something', value: 0 }
       })
     })
@@ -439,7 +439,7 @@ describe('src/Core', () => {
         bytesUploaded: 0,
         bytesTotal: 17175,
         uploadComplete: false,
-        uploadStarted: false
+        uploadStarted: null
       })
     })
   })
@@ -519,7 +519,7 @@ describe('src/Core', () => {
         bytesUploaded: 0,
         bytesTotal: 17175,
         uploadComplete: false,
-        uploadStarted: false,
+        uploadStarted: null,
         postprocess: { mode: 'determinate', message: 'something', value: 0 }
       })
     })
@@ -546,7 +546,7 @@ describe('src/Core', () => {
         bytesUploaded: 0,
         bytesTotal: 17175,
         uploadComplete: false,
-        uploadStarted: false
+        uploadStarted: null
       })
     })
   })
@@ -619,7 +619,7 @@ describe('src/Core', () => {
           bytesUploaded: 0,
           percentage: 0,
           uploadComplete: false,
-          uploadStarted: false
+          uploadStarted: null
         },
         remote: '',
         size: 17175,
@@ -991,7 +991,7 @@ describe('src/Core', () => {
         bytesUploaded: 12345,
         bytesTotal: 17175,
         uploadComplete: false,
-        uploadStarted: false
+        uploadStarted: null
       })
 
       core.emit('upload-progress', file, {
@@ -1003,7 +1003,7 @@ describe('src/Core', () => {
         bytesUploaded: 17175,
         bytesTotal: 17175,
         uploadComplete: false,
-        uploadStarted: false
+        uploadStarted: null
       })
     })
 
@@ -1146,14 +1146,14 @@ describe('src/Core', () => {
         bytesUploaded: 0,
         bytesTotal: 17175,
         uploadComplete: false,
-        uploadStarted: false
+        uploadStarted: null
       })
       expect(core.getFile(file2.id).progress).toEqual({
         percentage: 0,
         bytesUploaded: 0,
         bytesTotal: 17175,
         uploadComplete: false,
-        uploadStarted: false
+        uploadStarted: null
       })
       expect(core.getState().totalProgress).toEqual(0)
       expect(resetProgressEvent.mock.calls.length).toEqual(1)

+ 9 - 0
packages/@uppy/core/types/core-tests.ts

@@ -17,3 +17,12 @@ import DefaultStore = require('@uppy/store-default');
   const store = DefaultStore();
   const uppy = Uppy({ store });
 }
+
+{
+  const uppy = Uppy()
+  // this doesn't exist but type checking works anyway :)
+  const f = uppy.getFile('virtual')
+  if (f && f.progress && f.progress.uploadStarted === null) {
+    f.progress.uploadStarted = Date.now()
+  }
+}

+ 2 - 2
packages/@uppy/transloadit/src/index.test.js

@@ -51,7 +51,7 @@ describe('Transloadit', () => {
       const fileID = Object.keys(uppy.getState().files)[0]
 
       expect(err.message).toBe('Failure!')
-      expect(uppy.getFile(fileID).progress.uploadStarted).toBe(false)
+      expect(uppy.getFile(fileID).progress.uploadStarted).toBe(null)
     })
   })
 
@@ -79,7 +79,7 @@ describe('Transloadit', () => {
       const fileID = Object.keys(uppy.getState().files)[0]
 
       expect(err.message).toBe('Transloadit: Could not create Assembly: VIDEO_ENCODE_VALIDATION')
-      expect(uppy.getFile(fileID).progress.uploadStarted).toBe(false)
+      expect(uppy.getFile(fileID).progress.uploadStarted).toBe(null)
     })
   })
 })

+ 1 - 1
packages/@uppy/utils/types/index.d.ts

@@ -148,7 +148,7 @@ declare module '@uppy/utils' {
     name: string;
     preview?: string;
     progress?: {
-      uploadStarted: number;
+      uploadStarted: number | null;
       uploadComplete: boolean;
       percentage: number;
       bytesUploaded: number;