|
@@ -123,31 +123,32 @@ export default class View {
|
|
const { folders, files } = this.plugin.getPluginState()
|
|
const { folders, files } = this.plugin.getPluginState()
|
|
const items = this.filterItems(folders.concat(files))
|
|
const items = this.filterItems(folders.concat(files))
|
|
// Shift-clicking selects a single consecutive list of items
|
|
// Shift-clicking selects a single consecutive list of items
|
|
- // starting at the previous click and deselects everything else.
|
|
|
|
|
|
+ // starting at the previous click.
|
|
if (this.lastCheckbox && this.isShiftKeyPressed) {
|
|
if (this.lastCheckbox && this.isShiftKeyPressed) {
|
|
|
|
+ const { currentSelection } = this.plugin.getPluginState()
|
|
const prevIndex = items.indexOf(this.lastCheckbox)
|
|
const prevIndex = items.indexOf(this.lastCheckbox)
|
|
const currentIndex = items.indexOf(file)
|
|
const currentIndex = items.indexOf(file)
|
|
- const currentSelection = (prevIndex < currentIndex)
|
|
|
|
|
|
+ const newSelection = (prevIndex < currentIndex)
|
|
? items.slice(prevIndex, currentIndex + 1)
|
|
? items.slice(prevIndex, currentIndex + 1)
|
|
: items.slice(currentIndex, prevIndex + 1)
|
|
: items.slice(currentIndex, prevIndex + 1)
|
|
- const reducedCurrentSelection = []
|
|
|
|
|
|
+ const reducedNewSelection = []
|
|
|
|
|
|
// Check restrictions on each file in currentSelection,
|
|
// Check restrictions on each file in currentSelection,
|
|
// reduce it to only contain files that pass restrictions
|
|
// reduce it to only contain files that pass restrictions
|
|
- for (const item of currentSelection) {
|
|
|
|
|
|
+ for (const item of newSelection) {
|
|
const { uppy } = this.plugin
|
|
const { uppy } = this.plugin
|
|
const restrictionError = uppy.validateRestrictions(
|
|
const restrictionError = uppy.validateRestrictions(
|
|
remoteFileObjToLocal(item),
|
|
remoteFileObjToLocal(item),
|
|
- [...uppy.getFiles(), ...reducedCurrentSelection],
|
|
|
|
|
|
+ [...uppy.getFiles(), ...reducedNewSelection],
|
|
)
|
|
)
|
|
|
|
|
|
if (!restrictionError) {
|
|
if (!restrictionError) {
|
|
- reducedCurrentSelection.push(item)
|
|
|
|
|
|
+ reducedNewSelection.push(item)
|
|
} else {
|
|
} else {
|
|
uppy.info({ message: restrictionError.message }, 'error', uppy.opts.infoTimeout)
|
|
uppy.info({ message: restrictionError.message }, 'error', uppy.opts.infoTimeout)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- this.plugin.setPluginState({ currentSelection: reducedCurrentSelection })
|
|
|
|
|
|
+ this.plugin.setPluginState({ currentSelection: [...new Set([...currentSelection, ...reducedNewSelection])] })
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|