mirror of
https://github.com/zoriya/flood.git
synced 2026-05-31 02:15:12 +00:00
client: add "Initial Seeding" context menu item
This commit is contained in:
@@ -12,6 +12,7 @@ import type {
|
||||
DeleteTorrentsOptions,
|
||||
MoveTorrentsOptions,
|
||||
SetTorrentContentsPropertiesOptions,
|
||||
SetTorrentsInitialSeedingOptions,
|
||||
SetTorrentsPriorityOptions,
|
||||
SetTorrentsSequentialOptions,
|
||||
SetTorrentsTrackersOptions,
|
||||
@@ -194,6 +195,19 @@ const TorrentActions = {
|
||||
return undefined;
|
||||
},
|
||||
|
||||
setInitialSeeding: (options: SetTorrentsInitialSeedingOptions) =>
|
||||
axios
|
||||
.patch(`${baseURI}api/torrents/initial-seeding`, options)
|
||||
.then((json) => json.data)
|
||||
.then(
|
||||
() => {
|
||||
// do nothing.
|
||||
},
|
||||
() => {
|
||||
// do nothing.
|
||||
},
|
||||
),
|
||||
|
||||
setPriority: (options: SetTorrentsPriorityOptions) =>
|
||||
axios
|
||||
.patch(`${baseURI}api/torrents/priority`, options)
|
||||
|
||||
@@ -13,26 +13,23 @@ import UIActions from '../../actions/UIActions';
|
||||
|
||||
import type {ContextMenuItem} from '../../stores/UIStore';
|
||||
|
||||
// TODO: need to create a generic component if there are more menu items like this.
|
||||
const InlineSequentialCheckbox: FC = observer(() => {
|
||||
const {selectedTorrents} = TorrentStore;
|
||||
const getLastSelectedTorrent = (): string => TorrentStore.selectedTorrents[TorrentStore.selectedTorrents.length - 1];
|
||||
|
||||
return (
|
||||
const InlineTorrentPropertyCheckbox: FC<{property: keyof TorrentProperties}> = observer(
|
||||
({property}: {property: keyof TorrentProperties}) => (
|
||||
<label className="toggle-input checkbox" style={{display: 'inline'}}>
|
||||
<div className="toggle-input__indicator">
|
||||
<div
|
||||
className="toggle-input__indicator__icon"
|
||||
style={{
|
||||
opacity: TorrentStore.torrents[selectedTorrents[selectedTorrents.length - 1]].isSequential
|
||||
? '1'
|
||||
: undefined,
|
||||
opacity: TorrentStore.torrents[getLastSelectedTorrent()][property] ? '1' : undefined,
|
||||
}}>
|
||||
<Checkmark />
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
);
|
||||
});
|
||||
),
|
||||
);
|
||||
|
||||
const handleTorrentDownload = (hash: TorrentProperties['hash']): void => {
|
||||
const {baseURI} = ConfigStore;
|
||||
@@ -124,10 +121,9 @@ const getContextMenuItems = (torrent: TorrentProperties): Array<ContextMenuItem>
|
||||
action: 'torrentDetails',
|
||||
label: TorrentContextMenuActions.torrentDetails.id,
|
||||
clickHandler: () => {
|
||||
const {selectedTorrents} = TorrentStore;
|
||||
UIActions.displayModal({
|
||||
id: 'torrent-details',
|
||||
hash: selectedTorrents[selectedTorrents.length - 1],
|
||||
hash: getLastSelectedTorrent(),
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -136,9 +132,8 @@ const getContextMenuItems = (torrent: TorrentProperties): Array<ContextMenuItem>
|
||||
action: 'torrentDownload',
|
||||
label: TorrentContextMenuActions.torrentDownload.id,
|
||||
clickHandler: (e) => {
|
||||
const {selectedTorrents} = TorrentStore;
|
||||
e.preventDefault();
|
||||
handleTorrentDownload(selectedTorrents[selectedTorrents.length - 1]);
|
||||
handleTorrentDownload(getLastSelectedTorrent());
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -149,6 +144,20 @@ const getContextMenuItems = (torrent: TorrentProperties): Array<ContextMenuItem>
|
||||
UIActions.displayModal({id: 'generate-magnet'});
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
action: 'setInitialSeeding',
|
||||
label: TorrentContextMenuActions.setInitialSeeding.id,
|
||||
clickHandler: () => {
|
||||
const {selectedTorrents} = TorrentStore;
|
||||
TorrentActions.setInitialSeeding({
|
||||
hashes: selectedTorrents,
|
||||
isInitialSeeding: !TorrentStore.torrents[getLastSelectedTorrent()].isInitialSeeding,
|
||||
});
|
||||
},
|
||||
dismissMenu: false,
|
||||
labelAction: () => <InlineTorrentPropertyCheckbox property="isInitialSeeding" />,
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
action: 'setSequential',
|
||||
@@ -157,11 +166,11 @@ const getContextMenuItems = (torrent: TorrentProperties): Array<ContextMenuItem>
|
||||
const {selectedTorrents} = TorrentStore;
|
||||
TorrentActions.setSequential({
|
||||
hashes: selectedTorrents,
|
||||
isSequential: !TorrentStore.torrents[selectedTorrents[selectedTorrents.length - 1]].isSequential,
|
||||
isSequential: !TorrentStore.torrents[getLastSelectedTorrent()].isSequential,
|
||||
});
|
||||
},
|
||||
dismissMenu: false,
|
||||
labelAction: () => <InlineSequentialCheckbox />,
|
||||
labelAction: () => <InlineTorrentPropertyCheckbox property="isSequential" />,
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
|
||||
@@ -29,6 +29,9 @@ const TorrentContextMenuActions = {
|
||||
generateMagnet: {
|
||||
id: 'torrents.list.context.generate.magnet',
|
||||
},
|
||||
setInitialSeeding: {
|
||||
id: 'torrents.list.context.initial.seeding',
|
||||
},
|
||||
setSequential: {
|
||||
id: 'torrents.list.context.sequential',
|
||||
},
|
||||
|
||||
@@ -2221,6 +2221,12 @@
|
||||
"value": "Generate Magnet Link"
|
||||
}
|
||||
],
|
||||
"torrents.list.context.initial.seeding": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "Initial Seeding"
|
||||
}
|
||||
],
|
||||
"torrents.list.context.move": [
|
||||
{
|
||||
"type": 0,
|
||||
|
||||
@@ -317,6 +317,7 @@
|
||||
"torrents.list.context.move": "Set Torrent Location",
|
||||
"torrents.list.context.pause": "Pause",
|
||||
"torrents.list.context.download": "Download",
|
||||
"torrents.list.context.initial.seeding": "Initial Seeding",
|
||||
"torrents.list.context.priority": "Priority",
|
||||
"torrents.list.context.remove": "Remove",
|
||||
"torrents.list.context.sequential": "Sequential",
|
||||
|
||||
@@ -59,6 +59,7 @@ const defaultFloodSettings: Readonly<FloodSettings> = {
|
||||
{id: 'torrentDetails', visible: true},
|
||||
{id: 'torrentDownload', visible: true},
|
||||
{id: 'generateMagnet', visible: false},
|
||||
{id: 'setInitialSeeding', visible: false},
|
||||
{id: 'setSequential', visible: false},
|
||||
{id: 'setPriority', visible: false},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user