diff --git a/src/renderer/controllers/torrent-list-controller.js b/src/renderer/controllers/torrent-list-controller.js index af4051a..7c6fb1d 100644 --- a/src/renderer/controllers/torrent-list-controller.js +++ b/src/renderer/controllers/torrent-list-controller.js @@ -253,6 +253,33 @@ module.exports = class TorrentListController { } } + selectAllFiles (infoHash) { + const torrentSummary = TorrentSummary.getByKey(this.state, infoHash) + if (!torrentSummary || !torrentSummary.files || !torrentSummary.selections) return + + // Set all selections to true + torrentSummary.selections = torrentSummary.files.map(() => true) + + // Update WebTorrent if the torrent is active + if (torrentSummary.status !== 'paused') { + ipcRenderer.send('wt-select-files', infoHash, torrentSummary.selections) + } + } + + deselectAllFiles (infoHash) { + const torrentSummary = TorrentSummary.getByKey(this.state, infoHash) + if (!torrentSummary || !torrentSummary.files || !torrentSummary.selections) return + + // Set all selections to false + torrentSummary.selections = torrentSummary.files.map(() => false) + + // Update WebTorrent if the torrent is active + if (torrentSummary.status !== 'paused') { + ipcRenderer.send('wt-select-files', infoHash, torrentSummary.selections) + } + } + + openTorrentContextMenu (infoHash) { const torrentSummary = TorrentSummary.getByKey(this.state, infoHash) const menu = new remote.Menu() @@ -271,6 +298,16 @@ module.exports = class TorrentListController { type: 'separator' })) + menu.append(new remote.MenuItem({ + label: 'Select All Files', + click: () => this.selectAllFiles(torrentSummary.infoHash) + })) + + menu.append(new remote.MenuItem({ + label: 'Deselect All Files', + click: () => this.deselectAllFiles(torrentSummary.infoHash) + })) + if (torrentSummary.files) { menu.append(new remote.MenuItem({ label: process.platform === 'darwin' ? 'Show in Finder' : 'Show in Folder', diff --git a/src/renderer/main.js b/src/renderer/main.js index 8e8ebbb..3793dfc 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -271,7 +271,9 @@ const dispatchHandlers = { controllers.torrentList().saveTorrentFileAs(torrentKey), prioritizeTorrent: (infoHash) => controllers.torrentList().prioritizeTorrent(infoHash), resumePausedTorrents: () => controllers.torrentList().resumePausedTorrents(), - + selectAllFiles: (infoHash) => controllers.torrentList().selectAllFiles(infoHash), + deselectAllFiles: (infoHash) => controllers.torrentList().deselectAllFiles(infoHash), + // Playback playFile: (infoHash, index) => controllers.playback().playFile(infoHash, index), playPause: () => controllers.playback().playPause(),