API: rename /file-priority API

This commit is contained in:
Jesse Chan
2020-09-30 20:29:15 +08:00
parent 2443bc9303
commit 9bcf1d8e07
4 changed files with 20 additions and 22 deletions
+3 -3
View File
@@ -227,12 +227,12 @@ class ClientRequest {
}
setFilePriority(options) {
const fileIndices = getEnsuredArray(options.fileIndices);
const indices = getEnsuredArray(options.indices);
const hashes = getEnsuredArray(options.hashes);
hashes.forEach((hash) => {
fileIndices.forEach((fileIndex) => {
this.requests.push(getMethodCall('f.priority.set', [`${hash}:f${fileIndex}`, options.priority]));
indices.forEach((index) => {
this.requests.push(getMethodCall('f.priority.set', [`${hash}:f${index}`, options.priority]));
});
this.requests.push(getMethodCall('d.update_priorities', [hash]));
});
+2 -3
View File
@@ -218,11 +218,10 @@ const client = {
},
setFilePriority(user, services, hashes, data, callback) {
// TODO Add support for multiple hashes.
const {fileIndices} = data;
const {indices, priority} = data;
const request = new ClientRequest(user, services);
request.setFilePriority({hashes, fileIndices, priority: data.priority});
request.setFilePriority({hashes, indices, priority});
request.onComplete((response, error) => {
services.torrentService.fetchTorrentList();
callback(response, error);