From b997efc26e0134a66fc092bb833fefcccf713aec Mon Sep 17 00:00:00 2001 From: John Furrow Date: Wed, 31 Aug 2016 21:49:58 -0700 Subject: [PATCH] Handle changing multiple files' priority at once --- server/models/ClientRequest.js | 7 +++++-- server/models/FeedCollection.js | 2 +- server/models/client.js | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/models/ClientRequest.js b/server/models/ClientRequest.js index 76e9db64..8ecc2524 100644 --- a/server/models/ClientRequest.js +++ b/server/models/ClientRequest.js @@ -276,11 +276,14 @@ class ClientRequest { } setFilePriorityMethodCall(options) { + let fileIndices = this.getEnsuredArray(options.fileIndices); let hashes = this.getEnsuredArray(options.hashes); hashes.forEach((hash) => { - this.requests.push(this.getMethodCall('f.priority.set', - [`${hash}:f${options.fileIndex}`, options.priority])); + fileIndices.forEach((fileIndex) => { + this.requests.push(this.getMethodCall('f.priority.set', + [`${hash}:f${fileIndex}`, options.priority])); + }); this.requests.push(this.getMethodCall('d.update_priorities', [hash])); }); } diff --git a/server/models/FeedCollection.js b/server/models/FeedCollection.js index 9e127329..3a971503 100644 --- a/server/models/FeedCollection.js +++ b/server/models/FeedCollection.js @@ -154,7 +154,7 @@ class FeedCollection { init() { this.db.find({}, (err, docs) => { if (err) { - return ; + return; } let newItemHandler = this.handleNewItem.bind(this); diff --git a/server/models/client.js b/server/models/client.js index 29737e34..7d33b0c1 100644 --- a/server/models/client.js +++ b/server/models/client.js @@ -253,10 +253,10 @@ var client = { setFilePriority: (hashes, data, callback) => { // TODO Add support for multiple hashes. - let fileIndex = data.fileIndices[0]; + let fileIndices = data.fileIndices; let request = new ClientRequest(); - request.add('setFilePriority', {hashes, fileIndex, priority: data.priority}); + request.add('setFilePriority', {hashes, fileIndices, priority: data.priority}); request.onComplete(callback); request.send(); },