mirror of
https://github.com/transmission/transmission
synced 2025-02-20 13:16:53 +00:00
(trunk web) refactor sendTorrentCommand in my quest to allow remote.js to stand on its own
This also happens to fix #2322. Before, the callback would only update recently-active torrents. Now it updates all affected torrents.
This commit is contained in:
parent
5ba0a70848
commit
6138abe38f
2 changed files with 26 additions and 21 deletions
|
@ -1381,7 +1381,9 @@ Transmission.prototype =
|
|||
},
|
||||
|
||||
removeTorrents: function( torrents ) {
|
||||
this.remote.removeTorrents( torrents );
|
||||
var torrent_ids = jQuery.map(torrents, function(t) { return t.id(); } );
|
||||
var tr = this;
|
||||
this.remote.removeTorrents( torrent_ids, function(){ tr.refreshTorrents() } );
|
||||
},
|
||||
|
||||
removeTorrentsAndData: function( torrents ) {
|
||||
|
@ -1402,13 +1404,17 @@ Transmission.prototype =
|
|||
this.startTorrents( [ torrent ] );
|
||||
},
|
||||
startTorrents: function( torrents ) {
|
||||
this.remote.startTorrents( torrents );
|
||||
var torrent_ids = jQuery.map(torrents, function(t) { return t.id(); } );
|
||||
var tr = this;
|
||||
this.remote.startTorrents( torrent_ids, function(){ tr.refreshTorrents(torrent_ids) } );
|
||||
},
|
||||
verifyTorrent: function( torrent ) {
|
||||
this.verifyTorrents( [ torrent ] );
|
||||
},
|
||||
verifyTorrents: function( torrents ) {
|
||||
this.remote.verifyTorrents( torrents );
|
||||
var torrent_ids = jQuery.map(torrents, function(t) { return t.id(); } );
|
||||
var tr = this;
|
||||
this.remote.verifyTorrents( torrent_ids, function(){ tr.refreshTorrents(torrent_ids) } );
|
||||
},
|
||||
|
||||
stopSelectedTorrents: function( ) {
|
||||
|
@ -1421,7 +1427,9 @@ Transmission.prototype =
|
|||
this.stopTorrents( [ torrent ] );
|
||||
},
|
||||
stopTorrents: function( torrents ) {
|
||||
this.remote.stopTorrents( torrents );
|
||||
var torrent_ids = jQuery.map(torrents, function(t) { return t.id(); } );
|
||||
var tr = this;
|
||||
this.remote.stopTorrents( torrent_ids, function(){ tr.refreshTorrents(torrent_ids )} );
|
||||
},
|
||||
changeFileCommand: function(command, torrent, file) {
|
||||
this.remote.changeFileCommand(command, torrent, file)
|
||||
|
|
|
@ -146,28 +146,25 @@ TransmissionRemote.prototype =
|
|||
} );
|
||||
},
|
||||
|
||||
sendTorrentCommand: function( method, torrents ) {
|
||||
var remote = this;
|
||||
sendTorrentActionRequests: function( method, torrent_ids, callback ) {
|
||||
var o = {
|
||||
method: method,
|
||||
arguments: { ids: [ ] }
|
||||
arguments: { ids: torrent_ids }
|
||||
};
|
||||
if( torrents != null )
|
||||
for( var i=0, len=torrents.length; i<len; ++i )
|
||||
o.arguments.ids.push( torrents[i].id() );
|
||||
this.sendRequest( o, function( ) {
|
||||
remote._controller.refreshTorrents();
|
||||
} );
|
||||
|
||||
this.sendRequest( o, function( data ) {
|
||||
callback();
|
||||
});
|
||||
},
|
||||
|
||||
startTorrents: function( torrents ) {
|
||||
this.sendTorrentCommand( 'torrent-start', torrents );
|
||||
startTorrents: function( torrent_ids, callback ) {
|
||||
this.sendTorrentActionRequests( 'torrent-start', torrent_ids, callback );
|
||||
},
|
||||
stopTorrents: function( torrents ) {
|
||||
this.sendTorrentCommand( 'torrent-stop', torrents );
|
||||
stopTorrents: function( torrent_ids, callback ) {
|
||||
this.sendTorrentActionRequests( 'torrent-stop', torrent_ids, callback );
|
||||
},
|
||||
removeTorrents: function( torrents ) {
|
||||
this.sendTorrentCommand( 'torrent-remove', torrents );
|
||||
removeTorrents: function( torrent_ids, callback ) {
|
||||
this.sendTorrentActionRequests( 'torrent-remove', torrent_ids, callback );
|
||||
},
|
||||
removeTorrentsAndData: function( torrents ) {
|
||||
var remote = this;
|
||||
|
@ -186,8 +183,8 @@ TransmissionRemote.prototype =
|
|||
remote._controller.refreshTorrents();
|
||||
} );
|
||||
},
|
||||
verifyTorrents: function( torrents ) {
|
||||
this.sendTorrentCommand( 'torrent-verify', torrents );
|
||||
verifyTorrents: function( torrent_ids, callback ) {
|
||||
this.sendTorrentActionRequests( 'torrent-verify', torrent_ids, callback );
|
||||
},
|
||||
addTorrentByUrl: function( url, options ) {
|
||||
var remote = this;
|
||||
|
|
Loading…
Reference in a new issue