Added new feature to select and deselect torrent files

Use case:
If doiwnloading a tv show with 10 seasons and 500 files, I want to only download say 3 of those files, so that
 they can download quicker and i can start watching faster.
This allows customers to have a better UX experience
This commit is contained in:
Omar Najjar 2025-03-25 23:42:40 +11:00
parent e61501f13f
commit 935bacf551
2 changed files with 40 additions and 1 deletions

View file

@ -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',

View file

@ -271,6 +271,8 @@ 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),