From c07c4fd1cb9670d81472963c943dbc61e3535ccd Mon Sep 17 00:00:00 2001 From: Alexandr Korsak Date: Mon, 18 Dec 2017 13:20:18 +0300 Subject: [PATCH 1/2] Allow multiple file uploads on drag & drop --- src/components/structures/RoomView.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 138c110c4f..287509d962 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -45,6 +45,8 @@ import RoomViewStore from '../../stores/RoomViewStore'; import RoomScrollStateStore from '../../stores/RoomScrollStateStore'; import SettingsStore from "../../settings/SettingsStore"; +import _every from "lodash/every"; + const DEBUG = false; let debuglog = function() {}; @@ -855,8 +857,12 @@ module.exports = React.createClass({ ev.dataTransfer.dropEffect = 'none'; const items = ev.dataTransfer.items; - if (items.length == 1) { - if (items[0].kind == 'file') { + if (items.length >= 1) { + const isDraggingFiles = _every(items, function(item) { + return item.kind == 'file'; + }); + + if (isDraggingFiles) { this.setState({ draggingFile: true }); ev.dataTransfer.dropEffect = 'copy'; } @@ -867,10 +873,8 @@ module.exports = React.createClass({ ev.stopPropagation(); ev.preventDefault(); this.setState({ draggingFile: false }); - const files = ev.dataTransfer.files; - if (files.length == 1) { - this.uploadFile(files[0]); - } + const files = [...ev.dataTransfer.files]; + files.forEach(this.uploadFile); }, onDragLeaveOrEnd: function(ev) { From 78af02b29b6ac127573caeb2c4b2897521f41146 Mon Sep 17 00:00:00 2001 From: Alexandr Korsak Date: Mon, 18 Dec 2017 15:51:01 +0300 Subject: [PATCH 2/2] Replace lodash/every by Array.prototype.every function --- src/components/structures/RoomView.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 287509d962..e240ab38d5 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -45,8 +45,6 @@ import RoomViewStore from '../../stores/RoomViewStore'; import RoomScrollStateStore from '../../stores/RoomScrollStateStore'; import SettingsStore from "../../settings/SettingsStore"; -import _every from "lodash/every"; - const DEBUG = false; let debuglog = function() {}; @@ -856,9 +854,9 @@ module.exports = React.createClass({ ev.dataTransfer.dropEffect = 'none'; - const items = ev.dataTransfer.items; + const items = [...ev.dataTransfer.items]; if (items.length >= 1) { - const isDraggingFiles = _every(items, function(item) { + const isDraggingFiles = items.every(function(item) { return item.kind == 'file'; });