Skip to content

Commit 648ae33

Browse files
authored
Fix for using selected_files from previous downloads (#8413)
2 parents b291c08 + 9000c47 commit 648ae33

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/tribler/ui/src/components/add-torrent.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import { useTranslation } from "react-i18next";
1616
export function AddTorrent() {
1717
const { t } = useTranslation();
1818
const navigate = useNavigate();
19-
const inputRef = useRef<HTMLInputElement | null>(null);
19+
const fileInputRef = useRef<HTMLInputElement | null>(null);
20+
const uriInputRef = useRef<HTMLInputElement | null>(null);
2021

2122
const [urlDialogOpen, setUrlDialogOpen] = useState<boolean>(false);
2223
const [uriInput, setUriInput] = useState('');
@@ -47,8 +48,8 @@ export function AddTorrent() {
4748
</DropdownMenuItem>
4849
<DropdownMenuItem
4950
onClick={() => {
50-
if (inputRef && inputRef.current) {
51-
inputRef.current.click();
51+
if (fileInputRef && fileInputRef.current) {
52+
fileInputRef.current.click();
5253
}
5354
}}>
5455
<FileIcon className="mr-2 h-4 w-4" />
@@ -74,10 +75,9 @@ export function AddTorrent() {
7475
{t('MagnetDialogInputLabel')}
7576
<div className="grid grid-cols-6 items-center gap-4">
7677
<Input
78+
ref={uriInputRef}
7779
id="uri"
7880
className="col-span-5 pt-0"
79-
value={uriInput}
80-
onChange={(event) => setUriInput(event.target.value)}
8181
/>
8282
</div>
8383
</div>
@@ -86,7 +86,8 @@ export function AddTorrent() {
8686
variant="outline"
8787
type="submit"
8888
onClick={() => {
89-
if (uriInput) {
89+
if (uriInputRef.current?.value) {
90+
setUriInput(uriInputRef.current.value);
9091
setTorrent(undefined);
9192
setUrlDialogOpen(false);
9293
(async () => {
@@ -126,7 +127,7 @@ export function AddTorrent() {
126127

127128
<input
128129
style={{ display: 'none' }}
129-
ref={inputRef}
130+
ref={fileInputRef}
130131
type="file"
131132
accept=".torrent"
132133
onChange={(event) => {

src/tribler/ui/src/dialogs/SaveAs.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default function SaveAs(props: SaveAsProps & JSX.IntrinsicAttributes & Di
121121
setMoveCompleted(false);
122122
setError(undefined);
123123
setExists(false);
124-
setFiles([])
124+
setFiles([]);
125125
const newSettings = await triblerService.getSettings();
126126
if (newSettings === undefined) {
127127
setError(`${t("ToastErrorGetSettings")} ${t("ToastErrorGenNetworkErr")}`);
@@ -133,13 +133,14 @@ export default function SaveAs(props: SaveAsProps & JSX.IntrinsicAttributes & Di
133133
const safeSeeding = !!newSettings?.libtorrent?.download_defaults?.safeseeding_enabled;
134134
const safeDownloading = !!newSettings?.libtorrent?.download_defaults?.anonymity_enabled;
135135
setSettings(newSettings);
136-
setParams({
137-
...params,
136+
setParams(prev => ({
137+
...prev,
138138
destination: newSettings?.libtorrent.download_defaults.saveas ?? '',
139139
completed_dir: newSettings?.libtorrent.download_defaults.completed_dir ?? '',
140140
anon_hops: safeDownloading ? newSettings.libtorrent.download_defaults.number_hops : 0,
141141
safe_seeding: safeSeeding,
142-
});
142+
selected_files: []
143+
}));
143144
setMoveCompleted((newSettings?.libtorrent?.download_defaults.completed_dir ?? '').length > 0);
144145

145146
// Retrieve metainfo

src/tribler/ui/src/dialogs/SelectRemotePath.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ export default function SelectRemotePath(props: SelectRemotePathProps & JSX.Intr
6666
<DialogTitle>{selectDir ? t('PleaseSelectDirectory') : t('PleaseSelectFile')}</DialogTitle>
6767
<DialogDescription className="text-base break-all">
6868
{(currentPath || initialPath).split(separator).map((dir, index, array) => {
69-
if (dir.length == 0 && index == 0) return <>{separator}</>
69+
if (dir.length == 0 && index == 0) return <span key={index}>{separator}</span>
7070
else if (dir.length == 0) return
7171
return (
72-
<>
72+
<span key={index}>
7373
<a className="cursor-pointer hover:text-black dark:hover:text-white"
7474
onClick={(event) => {
7575
let path = array.slice(0, index + 1).join(separator) + separator;
@@ -83,7 +83,7 @@ export default function SelectRemotePath(props: SelectRemotePathProps & JSX.Intr
8383
{dir}
8484
</a>
8585
{dir.endsWith(separator) ? "" : separator}
86-
</>
86+
</span>
8787
)
8888
})}
8989
</DialogDescription>

0 commit comments

Comments
 (0)