Skip to content

Commit

Permalink
Only start downloading metainfo after "Add" is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman committed Jan 24, 2025
1 parent b2ad380 commit 4045f93
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/tribler/ui/src/components/add-torrent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { useTranslation } from "react-i18next";
export function AddTorrent() {
const { t } = useTranslation();
const navigate = useNavigate();
const inputRef = useRef<HTMLInputElement | null>(null);
const fileInputRef = useRef<HTMLInputElement | null>(null);
const uriInputRef = useRef<HTMLInputElement | null>(null);

const [urlDialogOpen, setUrlDialogOpen] = useState<boolean>(false);
const [uriInput, setUriInput] = useState('');
Expand Down Expand Up @@ -47,8 +48,8 @@ export function AddTorrent() {
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
if (inputRef && inputRef.current) {
inputRef.current.click();
if (fileInputRef && fileInputRef.current) {
fileInputRef.current.click();
}
}}>
<FileIcon className="mr-2 h-4 w-4" />
Expand All @@ -74,10 +75,9 @@ export function AddTorrent() {
{t('MagnetDialogInputLabel')}
<div className="grid grid-cols-6 items-center gap-4">
<Input
ref={uriInputRef}
id="uri"
className="col-span-5 pt-0"
value={uriInput}
onChange={(event) => setUriInput(event.target.value)}
/>
</div>
</div>
Expand All @@ -86,7 +86,8 @@ export function AddTorrent() {
variant="outline"
type="submit"
onClick={() => {
if (uriInput) {
if (uriInputRef.current?.value) {
setUriInput(uriInputRef.current.value);
setTorrent(undefined);
setUrlDialogOpen(false);
setSaveAsDialogOpen(true);
Expand Down Expand Up @@ -117,7 +118,7 @@ export function AddTorrent() {

<input
style={{ display: 'none' }}
ref={inputRef}
ref={fileInputRef}
type="file"
accept=".torrent"
onChange={(event) => {
Expand Down

0 comments on commit 4045f93

Please sign in to comment.