Skip to content

Commit

Permalink
Support changing the storage folder for multiple torrents at once
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman committed Jan 18, 2025
1 parent 4270980 commit 2f36aee
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/tribler/ui/src/pages/Downloads/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,20 @@ export default function Actions({ selectedDownloads }: { selectedDownloads: Down
else if (files.length > 1) downloadFilesAsZip(files, 'torrents.zip');
}
const onMoveDownload = () => {
if (selectedDownloads.length == 1) {
if (selectedDownloads.length > 0) {
setStorageLocation(selectedDownloads[0].destination);
setStorageDialogOpen(true);
}
}
const onMoveDownloadConfirmed = () => {
triblerService.moveDownload(selectedDownloads[0].infohash, storageLocation).then(async (response) => {
if (response === undefined) {
toast.error(`${t("ToastErrorDownloadMove")} ${t("ToastErrorGenNetworkErr")}`);
} else if (isErrorDict(response)) {
toast.error(`${t("ToastErrorDownloadMove")} ${response.error.message}`);
}
selectedDownloads.forEach((download) => {
triblerService.moveDownload(download.infohash, storageLocation).then(async (response) => {
if (response === undefined) {
toast.error(`${t("ToastErrorDownloadMove")} ${t("ToastErrorGenNetworkErr")}`);
} else if (isErrorDict(response)) {
toast.error(`${t("ToastErrorDownloadMove")} ${response.error.message}`);
}
});
});
setStorageDialogOpen(false);
}
Expand Down Expand Up @@ -219,7 +221,7 @@ export default function Actions({ selectedDownloads }: { selectedDownloads: Down
<ExternalLinkIcon className="mr-2 h-4 w-4" />
{t('ExportTorrent')}
</DropdownMenuItem>
<DropdownMenuItem onClick={() => { onMoveDownload() }} disabled={selectedDownloads.length !== 1}>
<DropdownMenuItem onClick={() => { onMoveDownload() }} disabled={selectedDownloads.length < 1}>
<MoveIcon className="mr-2 h-4 w-4" />
{t('MoveStorage')}
</DropdownMenuItem>
Expand Down

0 comments on commit 2f36aee

Please sign in to comment.