diff --git a/src/plugins/GoldenRetriever/index.js b/src/plugins/GoldenRetriever/index.js index c82b190e2..547b3249c 100644 --- a/src/plugins/GoldenRetriever/index.js +++ b/src/plugins/GoldenRetriever/index.js @@ -170,8 +170,6 @@ module.exports = class GoldenRetriever extends Plugin { } const updatedFile = Object.assign({}, originalFile, updatedFileData) updatedFiles[fileID] = updatedFile - - this.uppy.generatePreview(updatedFile) }) this.uppy.setState({ diff --git a/src/plugins/ThumbnailGenerator/index.js b/src/plugins/ThumbnailGenerator/index.js index 8222be90e..774b9306e 100644 --- a/src/plugins/ThumbnailGenerator/index.js +++ b/src/plugins/ThumbnailGenerator/index.js @@ -21,6 +21,7 @@ module.exports = class ThumbnailGenerator extends Plugin { this.opts = Object.assign({}, defaultOptions, opts) this.addToQueue = this.addToQueue.bind(this) + this.onRestored = this.onRestored.bind(this) } /** @@ -194,10 +195,24 @@ module.exports = class ThumbnailGenerator extends Plugin { return Promise.resolve() } + onRestored () { + const fileIDs = Object.keys(this.uppy.getState().files) + fileIDs.forEach((fileID) => { + const file = this.uppy.getFile(fileID) + if (!file.isRestored) return + // Only add blob URLs; they are likely invalid after being restored. + if (!file.preview || /^blob:/.test(file.preview)) { + this.addToQueue(file) + } + }) + } + install () { this.uppy.on('file-added', this.addToQueue) + this.uppy.on('restored', this.onRestored) } uninstall () { this.uppy.off('file-added', this.addToQueue) + this.uppy.off('restored', this.onRestored) } }