From 71ce340e64fe375030a86e5f45c6ddcc4ad3f3d9 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Sun, 13 Dec 2020 16:56:39 +0800 Subject: [PATCH] TorrentActions: don't send empty start/stop requests --- .../src/javascript/actions/TorrentActions.ts | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/client/src/javascript/actions/TorrentActions.ts b/client/src/javascript/actions/TorrentActions.ts index 183853ee..3efc550b 100644 --- a/client/src/javascript/actions/TorrentActions.ts +++ b/client/src/javascript/actions/TorrentActions.ts @@ -156,31 +156,39 @@ const TorrentActions = { }, ), - startTorrents: (options: StartTorrentsOptions) => - axios - .post(`${baseURI}api/torrents/start`, options) - .then((json) => json.data) - .then( - () => { - // do nothing. - }, - () => { - // do nothing. - }, - ), + startTorrents: async (options: StartTorrentsOptions): Promise => { + if (options.hashes.length > 0) { + return axios + .post(`${baseURI}api/torrents/start`, options) + .then((json) => json.data) + .then( + () => { + // do nothing. + }, + () => { + // do nothing. + }, + ); + } + return undefined; + }, - stopTorrents: (options: StopTorrentsOptions) => - axios - .post(`${baseURI}api/torrents/stop`, options) - .then((json) => json.data) - .then( - () => { - // do nothing. - }, - () => { - // do nothing. - }, - ), + stopTorrents: async (options: StopTorrentsOptions): Promise => { + if (options.hashes.length > 0) { + return axios + .post(`${baseURI}api/torrents/stop`, options) + .then((json) => json.data) + .then( + () => { + // do nothing. + }, + () => { + // do nothing. + }, + ); + } + return undefined; + }, setPriority: (options: SetTorrentsPriorityOptions) => axios