From d84c8aacb879d01c0e3eafeb87d3a5dfa73340fe Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Sun, 21 Feb 2021 23:37:54 +0800 Subject: [PATCH] client: add "Reannounce" action --- client/src/javascript/actions/TorrentActions.ts | 14 ++++++++++++++ .../torrent-list/TorrentListContextMenu.tsx | 10 ++++++++++ .../constants/TorrentContextMenuActions.ts | 1 + client/src/javascript/i18n/strings/en.json | 1 + shared/constants/defaultFloodSettings.ts | 1 + 5 files changed, 27 insertions(+) diff --git a/client/src/javascript/actions/TorrentActions.ts b/client/src/javascript/actions/TorrentActions.ts index 5a84250f..1f7167d7 100644 --- a/client/src/javascript/actions/TorrentActions.ts +++ b/client/src/javascript/actions/TorrentActions.ts @@ -8,6 +8,7 @@ import UIStore from '@client/stores/UIStore'; import type { AddTorrentByFileOptions, AddTorrentByURLOptions, + ReannounceTorrentsOptions, SetTorrentsTagsOptions, } from '@shared/schema/api/torrents'; import type { @@ -194,6 +195,19 @@ const TorrentActions = { }, ), + reannounce: (options: ReannounceTorrentsOptions) => + axios + .post(`${baseURI}api/torrents/reannounce`, options) + .then((json) => json.data) + .then( + () => { + // do nothing. + }, + () => { + // do nothing. + }, + ), + startTorrents: async (options: StartTorrentsOptions): Promise => { if (options.hashes.length > 0) { return axios diff --git a/client/src/javascript/components/torrent-list/TorrentListContextMenu.tsx b/client/src/javascript/components/torrent-list/TorrentListContextMenu.tsx index 5e87a1c3..a8b7c563 100644 --- a/client/src/javascript/components/torrent-list/TorrentListContextMenu.tsx +++ b/client/src/javascript/components/torrent-list/TorrentListContextMenu.tsx @@ -74,6 +74,16 @@ const getContextMenuItems = (torrent: TorrentProperties): Array }); }, }, + { + type: 'action', + action: 'reannounce', + label: TorrentContextMenuActions.reannounce, + clickHandler: () => { + TorrentActions.reannounce({ + hashes: TorrentStore.selectedTorrents as [string, ...string[]], + }); + }, + }, { type: 'separator', }, diff --git a/client/src/javascript/constants/TorrentContextMenuActions.ts b/client/src/javascript/constants/TorrentContextMenuActions.ts index 7262c3b3..28be027e 100644 --- a/client/src/javascript/constants/TorrentContextMenuActions.ts +++ b/client/src/javascript/constants/TorrentContextMenuActions.ts @@ -3,6 +3,7 @@ const TorrentContextMenuActions = { stop: 'torrents.list.context.stop', remove: 'torrents.list.context.remove', checkHash: 'torrents.list.context.check.hash', + reannounce: 'torrents.list.context.reannounce', setTaxonomy: 'torrents.list.context.set.tags', move: 'torrents.list.context.move', setTrackers: 'torrents.list.context.set.trackers', diff --git a/client/src/javascript/i18n/strings/en.json b/client/src/javascript/i18n/strings/en.json index b5eea887..a92c8903 100644 --- a/client/src/javascript/i18n/strings/en.json +++ b/client/src/javascript/i18n/strings/en.json @@ -324,6 +324,7 @@ "torrents.list.context.move": "Set Torrent Location", "torrents.list.context.pause": "Pause", "torrents.list.context.priority": "Priority", + "torrents.list.context.reannounce": "Reannounce", "torrents.list.context.remove": "Remove", "torrents.list.context.sequential": "Sequential", "torrents.list.context.set.tags": "Set Tags", diff --git a/shared/constants/defaultFloodSettings.ts b/shared/constants/defaultFloodSettings.ts index 736b0c55..e5c93696 100644 --- a/shared/constants/defaultFloodSettings.ts +++ b/shared/constants/defaultFloodSettings.ts @@ -53,6 +53,7 @@ const defaultFloodSettings: Readonly = { {id: 'stop', visible: true}, {id: 'remove', visible: true}, {id: 'checkHash', visible: true}, + {id: 'reannounce', visible: false}, {id: 'setTaxonomy', visible: true}, {id: 'move', visible: true}, {id: 'setTrackers', visible: false},