Forráskód Böngészése

Fix broken previews after cropping (#4926)

* ThumbnailGenerator.js - make sure thumbnail loads after image editing

* tests - account for additional event
Evgenia Karunus 1 éve
szülő
commit
a507d2eec3

+ 2 - 0
packages/@uppy/thumbnail-generator/src/index.js

@@ -373,6 +373,7 @@ export default class ThumbnailGenerator extends UIPlugin {
       this.uppy.on('thumbnail:request', this.onFileAdded)
       this.uppy.on('thumbnail:cancel', this.onCancelRequest)
     } else {
+      this.uppy.on('thumbnail:request', this.onFileAdded)
       this.uppy.on('file-added', this.onFileAdded)
       this.uppy.on('restored', this.onRestored)
     }
@@ -390,6 +391,7 @@ export default class ThumbnailGenerator extends UIPlugin {
       this.uppy.off('thumbnail:request', this.onFileAdded)
       this.uppy.off('thumbnail:cancel', this.onCancelRequest)
     } else {
+      this.uppy.off('thumbnail:request', this.onFileAdded)
       this.uppy.off('file-added', this.onFileAdded)
       this.uppy.off('restored', this.onRestored)
     }

+ 3 - 3
packages/@uppy/thumbnail-generator/src/index.test.js

@@ -52,7 +52,7 @@ describe('uploader/ThumbnailGeneratorPlugin', () => {
       plugin.addToQueue = vi.fn()
       plugin.install()
 
-      expect(core.on).toHaveBeenCalledTimes(4)
+      expect(core.on).toHaveBeenCalledTimes(5)
       expect(core.on).toHaveBeenCalledWith('file-added', plugin.onFileAdded)
     })
   })
@@ -68,11 +68,11 @@ describe('uploader/ThumbnailGeneratorPlugin', () => {
       plugin.addToQueue = vi.fn()
       plugin.install()
 
-      expect(core.on).toHaveBeenCalledTimes(4)
+      expect(core.on).toHaveBeenCalledTimes(5)
 
       plugin.uninstall()
 
-      expect(core.off).toHaveBeenCalledTimes(4)
+      expect(core.off).toHaveBeenCalledTimes(5)
       expect(core.off).toHaveBeenCalledWith('file-added', plugin.onFileAdded)
     })
   })