Skip to content

Commit

Permalink
Don't show SaveAs if no valid torrent is available from the uri
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Jan 21, 2025
1 parent ec4e59d commit cbab801
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/tribler/ui/src/components/add-torrent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@ export function AddTorrent() {
if (uriInput) {
setTorrent(undefined);
setUrlDialogOpen(false);
setSaveAsDialogOpen(true);
(async () => {
const response = await triblerService.getMetainfo(uriInput);
if (response === undefined) {
toast.error(`${t("ToastErrorDownloadStart")} ${t("ToastErrorGenNetworkErr")}`);
} else if (isErrorDict(response)){
toast.error(`${t("ToastErrorDownloadStart")} ${response.error.message}`);
} else {
setSaveAsDialogOpen(true);
}
})();
}
}}>
{t('Add')}
Expand Down Expand Up @@ -136,9 +145,9 @@ export function AddTorrent() {
(async () => {
const response = await triblerService.startDownloadFromFile(file);
if (response === undefined) {
toast.error(`${t("ToastErrorStartDownload")} ${t("ToastErrorGenNetworkErr")}`);
toast.error(`${t("ToastErrorDownloadStart")} ${t("ToastErrorGenNetworkErr")}`);
} else if (isErrorDict(response)){
toast.error(`${t("ToastErrorStartDownload")} ${response.error.message}`);
toast.error(`${t("ToastErrorDownloadStart")} ${response.error.message}`);
}
})();
}
Expand Down

0 comments on commit cbab801

Please sign in to comment.