Skip to content

A full-featured download manager.

refactor: batch change task option api

Dr_rOotb81298d6ebf5
diff --git a/src/renderer/api/Api.js b/src/renderer/api/Api.js
index 5b261883..e88351ab 100644
--- a/src/renderer/api/Api.js
+++ b/src/renderer/api/Api.js
@@ -169,18 +169,6 @@ export default class Api {
return this.client.call('changeOption', ...args)
}
- batchChangeOption (params = {}) {
- let { gids, options = {} } = params
- options = formatOptionsForEngine(options)
-
- const data = gids.map((gid, index) => {
- const kebabOptions = changeKeysToKebabCase(options)
- const args = compactUndefined([gid, kebabOptions])
- return [ 'aria2.changeOption', ...args ]
- })
- return this.client.multicall(data)
- }
-
getGlobalStat () {
return this.client.call('getGlobalStat')
}
@@ -334,4 +322,20 @@ export default class Api {
const args = compactUndefined([gid])
return this.client.call('removeDownloadResult', ...args)
}
+
+ multicall (method, params = {}) {
+ let { gids, options = {} } = params
+ options = formatOptionsForEngine(options)
+
+ const data = gids.map((gid, index) => {
+ const kebabOptions = changeKeysToKebabCase(options)
+ const args = compactUndefined([gid, kebabOptions])
+ return [ method, ...args ]
+ })
+ return this.client.multicall(data)
+ }
+
+ batchChangeOption (params = {}) {
+ return this.multicall('aria2.changeOption', params)
+ }
}