feat(delete-all-torrents): added remove all torrents capability to the Transfers menu

This commit is contained in:
Sharon Grossman
2017-09-26 18:39:43 +03:00
committed by Mathias Rasmussen
parent 11b42e58c1
commit b7fedb1983
5 changed files with 72 additions and 1 deletions

View File

@@ -201,6 +201,13 @@ module.exports = class TorrentListController {
}
}
confirmDeleteAllTorrents (deleteData) {
this.state.modal = {
id: 'delete-all-torrents-modal',
deleteData
}
}
// TODO: use torrentKey, not infoHash
deleteTorrent (infoHash, deleteData) {
ipcRenderer.send('wt-stop-torrenting', infoHash)
@@ -227,6 +234,26 @@ module.exports = class TorrentListController {
sound.play('DELETE')
}
deleteAllTorrents (deleteData) {
this.state.saved.torrents.forEach((summary) => {
ipcRenderer.send('wt-stop-torrenting', summary.infoHash)
// remove torrent and poster file
deleteFile(TorrentSummary.getTorrentPath(summary))
deleteFile(TorrentSummary.getPosterPath(summary))
if (deleteData) moveItemToTrash(summary)
dispatch('stateSave')
})
this.state.saved.torrents = []
// prevent user from going forward to a deleted torrent
this.state.location.clearForward('player')
sound.play('DELETE')
}
toggleSelectTorrent (infoHash) {
if (this.state.selectedInfoHash === infoHash) {
this.state.selectedInfoHash = null