Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed May 15, 2024
1 parent 8d17fb4 commit 1e4d54b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
8 changes: 3 additions & 5 deletions packages/@uppy/aws-s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,11 +836,9 @@ export default class AwsS3Multipart<
resolve(`upload ${removed} was removed`)
})

eventManager.onCancelAll(file.id, (options) => {
if (options?.reason === 'user') {
upload.abort()
this.resetUploaderReferences(file.id, { abort: true })
}
eventManager.onCancelAll(file.id, () => {
upload.abort()
this.resetUploaderReferences(file.id, { abort: true })
resolve(`upload ${file.id} was canceled`)
})

Expand Down
6 changes: 2 additions & 4 deletions packages/@uppy/companion-client/src/RequestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,8 @@ export default class RequestClient<M extends Meta, B extends Body> {
resolve()
}

const onCancelAll = ({ reason }: { reason?: string }) => {
if (reason === 'user') {
socketSend('cancel')
}
const onCancelAll = () => {
socketSend('cancel')
socketAbortController?.abort?.()
this.uppy.log(`upload ${file.id} was canceled`, 'info')
resolve()
Expand Down
10 changes: 5 additions & 5 deletions packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ export class Uppy<M extends Meta, B extends Body> {
}
}

removeFiles(fileIDs: string[], reason?: FileRemoveReason): void {
removeFiles(fileIDs: string[]): void {
const { files, currentUploads } = this.getState()
const updatedFiles = { ...files }
const updatedUploads = { ...currentUploads }
Expand Down Expand Up @@ -1173,7 +1173,7 @@ export class Uppy<M extends Meta, B extends Body> {

const removedFileIDs = Object.keys(removedFiles)
removedFileIDs.forEach((fileID) => {
this.emit('file-removed', removedFiles[fileID], reason)
this.emit('file-removed', removedFiles[fileID])
})

if (removedFileIDs.length > 5) {
Expand All @@ -1183,8 +1183,8 @@ export class Uppy<M extends Meta, B extends Body> {
}
}

removeFile(fileID: string, reason?: FileRemoveReason): void {
this.removeFiles([fileID], reason)
removeFile(fileID: string): void {
this.removeFiles([fileID])
}

pauseResume(fileID: string): boolean | undefined {
Expand Down Expand Up @@ -1288,7 +1288,7 @@ export class Uppy<M extends Meta, B extends Body> {

const fileIDs = Object.keys(files)
if (fileIDs.length) {
this.removeFiles(fileIDs, 'cancel-all')
this.removeFiles(fileIDs)
}

this.setState(defaultUploadState)
Expand Down
8 changes: 3 additions & 5 deletions packages/@uppy/tus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,9 @@ export default class Tus<M extends Meta, B extends Body> extends BasePlugin<
upload.abort()
})

eventManager.onCancelAll(file.id, ({ reason } = {}) => {
if (reason === 'user') {
queuedRequest.abort()
this.resetUploaderReferences(file.id, { abort: !!upload.url })
}
eventManager.onCancelAll(file.id, () => {
queuedRequest.abort()
this.resetUploaderReferences(file.id, { abort: !!upload.url })
resolve(`upload ${file.id} was canceled`)
})

Expand Down
6 changes: 2 additions & 4 deletions packages/@uppy/xhr-upload/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,8 @@ export default class XHRUpload<
})

events.onFileRemove(file.id, () => controller.abort())
events.onCancelAll(file.id, ({ reason }) => {
if (reason === 'user') {
controller.abort()
}
events.onCancelAll(file.id, () => {
controller.abort()
})

try {
Expand Down

0 comments on commit 1e4d54b

Please sign in to comment.