feat(web): add context menu items for sequential downloading

This commit is contained in:
Hendrik Luup 2024-03-10 14:49:46 +02:00
parent d19b534c1d
commit 2ec40cea02
4 changed files with 40 additions and 0 deletions

View File

@ -12,6 +12,14 @@ export class ActionManager extends EventTarget {
shortcut: 'D',
text: 'Deselect all',
},
'disable-sequential-downloading': {
enabled: true,
text: 'Disable sequential downloading',
},
'enable-sequential-downloading': {
enabled: true,
text: 'Enable sequential downloading',
},
'move-bottom': { enabled: false, text: 'Move to the back of the queue' },
'move-down': { enabled: false, text: 'Move down in the queue' },
'move-top': { enabled: false, text: 'Move to the front of the queue' },

View File

@ -94,6 +94,9 @@ export class ContextMenu extends EventTarget {
add_item('remove-selected-torrents', true);
add_item('trash-selected-torrents', true);
add_separator();
add_item('enable-sequential-downloading');
add_item('disable-sequential-downloading');
add_separator();
add_item('verify-selected-torrents');
add_item('show-move-dialog');
add_item('show-rename-dialog');

View File

@ -281,6 +281,21 @@ export class Remote {
});
}
_setSequentialDownload(torrentIds, state, callback) {
const args = {
ids: torrentIds,
sequentialDownload: state,
};
this.sendRequest({ arguments: args, method: 'torrent-set' }, callback);
}
disableSequentialDownload(torrentIds, callback) {
this._setSequentialDownload(torrentIds, false, callback);
}
enableSequentialDownload(torrentIds, callback) {
this._setSequentialDownload(torrentIds, true, callback);
}
// Added queue calls
moveTorrentsToTop(torrent_ids, callback, context) {
this.sendTorrentActionRequests(

View File

@ -170,6 +170,12 @@ export class Transmission extends EventTarget {
? Prefs.DisplayFull
: Prefs.DisplayCompact;
break;
case 'enable-sequential-downloading':
this._enableSequentialDownload(this.getSelectedTorrents());
break;
case 'disable-sequential-downloading':
this._disableSequentialDownload(this.getSelectedTorrents());
break;
case 'trash-selected-torrents':
this._removeSelectedTorrents(true);
break;
@ -853,6 +859,14 @@ TODO: fix this when notifications get fixed
this,
);
}
_enableSequentialDownload(torrents) {
this.remote.enableSequentialDownload(Transmission._getTorrentIds(torrents));
}
_disableSequentialDownload(torrents) {
this.remote.disableSequentialDownload(
Transmission._getTorrentIds(torrents),
);
}
_verifyTorrents(torrents) {
this.remote.verifyTorrents(
Transmission._getTorrentIds(torrents),