Преглед изворни кода

aws-s3: fix incorrect comparison for `file-removed` (#3962)

Add check for file object vs file id
Merlijn Vos пре 2 година
родитељ
комит
222c00bb26
1 измењених фајлова са 6 додато и 2 уклоњено
  1. 6 2
      packages/@uppy/aws-s3/src/MiniXHRUpload.js

+ 6 - 2
packages/@uppy/aws-s3/src/MiniXHRUpload.js

@@ -100,8 +100,12 @@ export default class MiniXHRUpload {
   }
 
   #addEventHandlerForFile (eventName, fileID, eventHandler) {
-    this.uploaderEvents[fileID].on(eventName, (targetFileID) => {
-      if (fileID === targetFileID) eventHandler()
+    this.uploaderEvents[fileID].on(eventName, (fileOrID) => {
+      // TODO (major): refactor Uppy events to consistently send file objects (or consistently IDs)
+      // We created a generic `addEventListenerForFile` but not all events
+      // use file IDs, some use files, so we need to do this weird check.
+      const id = fileOrID?.id ?? fileOrID
+      if (fileID === id) eventHandler()
     })
   }