Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: use uploadStarted: null instead of false #1628

Merged
merged 2 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/@uppy/core/src/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Object {
"bytesUploaded": 0,
"percentage": 0,
"uploadComplete": false,
"uploadStarted": false,
"uploadStarted": null,
},
"remote": "",
"size": null,
Expand All @@ -54,7 +54,7 @@ Object {
"bytesUploaded": 0,
"percentage": 0,
"uploadComplete": false,
"uploadStarted": false,
"uploadStarted": null,
},
"remote": "",
"size": null,
Expand Down
4 changes: 2 additions & 2 deletions packages/@uppy/core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -450,7 +450,7 @@ class Uppy {
bytesUploaded: 0,
bytesTotal: size,
uploadComplete: false,
uploadStarted: false
uploadStarted: null
},
size: size,
isRemote: isRemote,
Expand Down
18 changes: 9 additions & 9 deletions packages/@uppy/core/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ describe('src/Core', () => {
bytesUploaded: 0,
bytesTotal: 17175,
uploadComplete: false,
uploadStarted: false,
uploadStarted: null,
preprocess: { mode: 'determinate', message: 'something', value: 0 }
})
})
Expand All @@ -439,7 +439,7 @@ describe('src/Core', () => {
bytesUploaded: 0,
bytesTotal: 17175,
uploadComplete: false,
uploadStarted: false
uploadStarted: null
})
})
})
Expand Down Expand Up @@ -519,7 +519,7 @@ describe('src/Core', () => {
bytesUploaded: 0,
bytesTotal: 17175,
uploadComplete: false,
uploadStarted: false,
uploadStarted: null,
postprocess: { mode: 'determinate', message: 'something', value: 0 }
})
})
Expand All @@ -546,7 +546,7 @@ describe('src/Core', () => {
bytesUploaded: 0,
bytesTotal: 17175,
uploadComplete: false,
uploadStarted: false
uploadStarted: null
})
})
})
Expand Down Expand Up @@ -619,7 +619,7 @@ describe('src/Core', () => {
bytesUploaded: 0,
percentage: 0,
uploadComplete: false,
uploadStarted: false
uploadStarted: null
},
remote: '',
size: 17175,
Expand Down Expand Up @@ -991,7 +991,7 @@ describe('src/Core', () => {
bytesUploaded: 12345,
bytesTotal: 17175,
uploadComplete: false,
uploadStarted: false
uploadStarted: null
})

core.emit('upload-progress', file, {
Expand All @@ -1003,7 +1003,7 @@ describe('src/Core', () => {
bytesUploaded: 17175,
bytesTotal: 17175,
uploadComplete: false,
uploadStarted: false
uploadStarted: null
})
})

Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions packages/@uppy/core/types/core-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
4 changes: 2 additions & 2 deletions packages/@uppy/transloadit/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

Expand Down Expand Up @@ -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)
})
})
})
2 changes: 1 addition & 1 deletion packages/@uppy/utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ declare module '@uppy/utils' {
name: string;
preview?: string;
progress?: {
uploadStarted: number;
uploadStarted: number | null;
uploadComplete: boolean;
percentage: number;
bytesUploaded: number;
Expand Down