feat(torrents): add support for dropping torrent to base just with window

This commit is contained in:
Alexey Kasyanchuk
2018-07-29 21:21:19 +03:00
parent 01a72e551f
commit 1442a65c6e
4 changed files with 65 additions and 6 deletions

View File

@ -147,6 +147,24 @@ class App extends Component {
changeLanguage(lang, () => this.forceUpdate())
})
const processTorrents = (files) => {
if(!files || files.length == 0)
return
torrentSocket.emit('dropTorrents', Array.from(files).filter(file => file.type == 'application/x-bittorrent').map(file => file.path))
}
document.addEventListener('dragover', (event) => {
event.stopPropagation();
event.preventDefault();
event.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}, false);
document.addEventListener('drop', (event) => {
event.stopPropagation();
event.preventDefault();
processTorrents(event.dataTransfer.files); // FileList object.
}, false);
window.router()
appReady = true;
}