|
@@ -53,8 +53,6 @@ type Processor = (
|
|
|
uploadID: string,
|
|
|
) => Promise<unknown> | void
|
|
|
|
|
|
-type FileRemoveReason = 'user' | 'cancel-all' | 'unmount'
|
|
|
-
|
|
|
type LogLevel = 'info' | 'warning' | 'error' | 'success'
|
|
|
|
|
|
export type UnknownPlugin<
|
|
@@ -228,7 +226,7 @@ export type NonNullableUppyOptions<M extends Meta, B extends Body> = Required<
|
|
|
|
|
|
export interface _UppyEventMap<M extends Meta, B extends Body> {
|
|
|
'back-online': () => void
|
|
|
- 'cancel-all': (reason: { reason?: FileRemoveReason }) => void
|
|
|
+ 'cancel-all': () => void
|
|
|
complete: (result: UploadResult<M, B>) => void
|
|
|
error: (
|
|
|
error: { name: string; message: string; details?: string },
|
|
@@ -236,7 +234,7 @@ export interface _UppyEventMap<M extends Meta, B extends Body> {
|
|
|
response?: UppyFile<M, B>['response'],
|
|
|
) => void
|
|
|
'file-added': (file: UppyFile<M, B>) => void
|
|
|
- 'file-removed': (file: UppyFile<M, B>, reason?: FileRemoveReason) => void
|
|
|
+ 'file-removed': (file: UppyFile<M, B>) => void
|
|
|
'files-added': (files: UppyFile<M, B>[]) => void
|
|
|
'info-hidden': () => void
|
|
|
'info-visible': () => void
|
|
@@ -1137,7 +1135,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 }
|
|
@@ -1197,7 +1195,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) {
|
|
@@ -1207,8 +1205,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 {
|
|
@@ -1305,21 +1303,18 @@ export class Uppy<M extends Meta, B extends Body> {
|
|
|
return this.#runUpload(uploadID)
|
|
|
}
|
|
|
|
|
|
- cancelAll({ reason = 'user' }: { reason?: FileRemoveReason } = {}): void {
|
|
|
- this.emit('cancel-all', { reason })
|
|
|
-
|
|
|
- // Only remove existing uploads if user is canceling
|
|
|
- if (reason === 'user') {
|
|
|
- const { files } = this.getState()
|
|
|
+ cancelAll(): void {
|
|
|
+ this.emit('cancel-all')
|
|
|
|
|
|
- const fileIDs = Object.keys(files)
|
|
|
- if (fileIDs.length) {
|
|
|
- this.removeFiles(fileIDs, 'cancel-all')
|
|
|
- }
|
|
|
+ const { files } = this.getState()
|
|
|
|
|
|
- this.setState(defaultUploadState)
|
|
|
- // todo should we call this.emit('reset-progress') like we do for resetProgress?
|
|
|
+ const fileIDs = Object.keys(files)
|
|
|
+ if (fileIDs.length) {
|
|
|
+ this.removeFiles(fileIDs)
|
|
|
}
|
|
|
+
|
|
|
+ this.setState(defaultUploadState)
|
|
|
+ // todo should we call this.emit('reset-progress') like we do for resetProgress?
|
|
|
}
|
|
|
|
|
|
retryUpload(fileID: string): Promise<UploadResult<M, B> | undefined> {
|
|
@@ -1818,12 +1813,12 @@ export class Uppy<M extends Meta, B extends Body> {
|
|
|
/**
|
|
|
* Uninstall all plugins and close down this Uppy instance.
|
|
|
*/
|
|
|
- destroy({ reason }: { reason?: FileRemoveReason } | undefined = {}): void {
|
|
|
+ destroy(): void {
|
|
|
this.log(
|
|
|
`Closing Uppy instance ${this.opts.id}: removing all files and uninstalling plugins`,
|
|
|
)
|
|
|
|
|
|
- this.cancelAll({ reason })
|
|
|
+ this.cancelAll()
|
|
|
|
|
|
this.#storeUnsubscribe()
|
|
|
|