Skip to content

Commit

Permalink
remove the reason from @uppy/transloadit
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed May 22, 2024
1 parent 8d454d5 commit 087ad5b
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions packages/@uppy/transloadit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,20 +441,14 @@ export default class Transloadit<
// TODO: this should not live inside a `file-removed` event but somewhere more deterministic.
// Such as inside the function where the assembly has succeeded or cancelled.
// For the use case of cancelling the assembly when needed, we should try to do that with just `cancel-all`.
const fileRemovedHandler = (
fileRemoved: UppyFile<M, B>,
reason?: string,
) => {
const fileRemovedHandler = (fileRemoved: UppyFile<M, B>) => {
// If the assembly has successfully completed, we do not need these checks.
// Otherwise we may cancel an assembly after it already succeeded
if (assembly.status?.ok === 'ASSEMBLY_COMPLETED') {
this.uppy.off('file-removed', fileRemovedHandler)
return
}
if (reason === 'cancel-all') {
assembly.close()
this.uppy.off('file-removed', fileRemovedHandler)
} else if (fileRemoved.id in updatedFiles) {
if (fileRemoved.id in updatedFiles) {
delete updatedFiles[fileRemoved.id]
const nbOfRemainingFiles = Object.keys(updatedFiles).length

Expand Down Expand Up @@ -667,10 +661,8 @@ export default class Transloadit<
/**
* When all files are removed, cancel in-progress Assemblies.
*/
#onCancelAll = async ({ reason }: { reason?: string } = {}) => {
#onCancelAll = async () => {
try {
if (reason !== 'user') return

const { uploadsAssemblies } = this.getPluginState()
const assemblyIDs = Object.values(uploadsAssemblies).flat(1)
const assemblies = assemblyIDs.map((assemblyID) =>
Expand Down

0 comments on commit 087ad5b

Please sign in to comment.