|
@@ -78,6 +78,8 @@ module.exports = class ProviderView {
|
|
|
|
|
|
// Visual
|
|
// Visual
|
|
this.render = this.render.bind(this)
|
|
this.render = this.render.bind(this)
|
|
|
|
+
|
|
|
|
+ this.plugin.setPluginState({ addingFiles: [] })
|
|
}
|
|
}
|
|
|
|
|
|
tearDown () {
|
|
tearDown () {
|
|
@@ -149,8 +151,14 @@ module.exports = class ProviderView {
|
|
this.lastCheckbox = undefined
|
|
this.lastCheckbox = undefined
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ hasFile (id) {
|
|
|
|
+ const { addingFiles } = this.plugin.getPluginState()
|
|
|
|
+ return addingFiles.some((file) => file.id === id)
|
|
|
|
+ }
|
|
|
|
+
|
|
addFile (file, isCheckbox = false) {
|
|
addFile (file, isCheckbox = false) {
|
|
const tagFile = {
|
|
const tagFile = {
|
|
|
|
+ id: this.providerFileToId(file),
|
|
source: this.plugin.id,
|
|
source: this.plugin.id,
|
|
data: this.plugin.getItemData(file),
|
|
data: this.plugin.getItemData(file),
|
|
name: this.plugin.getItemName(file) || this.plugin.getItemId(file),
|
|
name: this.plugin.getItemName(file) || this.plugin.getItemId(file),
|
|
@@ -174,12 +182,22 @@ module.exports = class ProviderView {
|
|
tagFile.preview = this.plugin.getItemThumbnailUrl(file)
|
|
tagFile.preview = this.plugin.getItemThumbnailUrl(file)
|
|
}
|
|
}
|
|
this.plugin.uppy.log('Adding remote file')
|
|
this.plugin.uppy.log('Adding remote file')
|
|
- this.plugin.uppy.addFile(tagFile)
|
|
|
|
|
|
+ const { addingFiles } = this.plugin.getPluginState()
|
|
|
|
+ this.plugin.setPluginState({
|
|
|
|
+ addingFiles: [...addingFiles, tagFile]
|
|
|
|
+ })
|
|
if (!isCheckbox) {
|
|
if (!isCheckbox) {
|
|
this.donePicking()
|
|
this.donePicking()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ removeFile (id) {
|
|
|
|
+ const { addingFiles } = this.plugin.getPluginState()
|
|
|
|
+ this.plugin.setPluginState({
|
|
|
|
+ addingFiles: addingFiles.filter((file) => file.id !== id)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Removes session token on client side.
|
|
* Removes session token on client side.
|
|
*/
|
|
*/
|
|
@@ -317,7 +335,7 @@ module.exports = class ProviderView {
|
|
}
|
|
}
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
- return (itemId in this.plugin.uppy.getState().files)
|
|
|
|
|
|
+ return this.hasFile(itemId)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -380,8 +398,8 @@ module.exports = class ProviderView {
|
|
// is removed and 'core:file-removed' is emitted.
|
|
// is removed and 'core:file-removed' is emitted.
|
|
const files = folder.files.concat([])
|
|
const files = folder.files.concat([])
|
|
for (const fileId of files) {
|
|
for (const fileId of files) {
|
|
- if (fileId in this.plugin.uppy.getState().files) {
|
|
|
|
- this.plugin.uppy.removeFile(fileId)
|
|
|
|
|
|
+ if (this.hasFile(fileId)) {
|
|
|
|
+ this.removeFile(fileId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
delete folders[folderId]
|
|
delete folders[folderId]
|
|
@@ -446,10 +464,8 @@ module.exports = class ProviderView {
|
|
const itemId = this.providerFileToId(item)
|
|
const itemId = this.providerFileToId(item)
|
|
if (this.plugin.isFolder(item)) {
|
|
if (this.plugin.isFolder(item)) {
|
|
this.removeFolder(itemId)
|
|
this.removeFolder(itemId)
|
|
- } else {
|
|
|
|
- if (itemId in this.plugin.uppy.getState().files) {
|
|
|
|
- this.plugin.uppy.removeFile(itemId)
|
|
|
|
- }
|
|
|
|
|
|
+ } else if (this.hasFile(itemId)) {
|
|
|
|
+ this.removeFile(itemId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -534,6 +550,13 @@ module.exports = class ProviderView {
|
|
}
|
|
}
|
|
|
|
|
|
donePicking () {
|
|
donePicking () {
|
|
|
|
+ const { addingFiles } = this.plugin.getPluginState()
|
|
|
|
+ addingFiles.forEach((file) => {
|
|
|
|
+ this.plugin.uppy.addFile(file)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ this.plugin.setPluginState({ addingFiles: [] })
|
|
|
|
+
|
|
const dashboard = this.plugin.uppy.getPlugin('Dashboard')
|
|
const dashboard = this.plugin.uppy.getPlugin('Dashboard')
|
|
if (dashboard) dashboard.hideAllPanels()
|
|
if (dashboard) dashboard.hideAllPanels()
|
|
}
|
|
}
|