diff --git a/src/components/AddTorrentModal.tsx b/src/components/AddTorrentModal.tsx index df19735..ab19507 100644 --- a/src/components/AddTorrentModal.tsx +++ b/src/components/AddTorrentModal.tsx @@ -1,6 +1,8 @@ import { useState, useRef } from 'react' import { Plus, X, Upload, CheckCircle, Check } from 'lucide-react' import { useAddTorrent, useCategories } from '../hooks/useTorrents' +import { PathInput } from './ui/PathInput' +import { usePathHistory } from '../hooks/usePathHistory' interface Props { open: boolean @@ -22,6 +24,7 @@ export function AddTorrentModal({ open, onClose }: Props) { const { data: categories = {} } = useCategories() const addMutation = useAddTorrent() + const { addPath } = usePathHistory() if (!open) return null @@ -44,6 +47,7 @@ export function AddTorrentModal({ open, onClose }: Props) { }, { onSuccess: () => { + if (savepath.trim()) addPath(savepath.trim()) setUrl('') setFiles([]) setCategory('') @@ -257,10 +261,9 @@ export function AddTorrentModal({ open, onClose }: Props) { - setSavepath(e.target.value)} + onChange={setSavepath} placeholder="Default" className="w-full px-3 py-2.5 rounded-xl border text-sm focus:outline-none transition-colors" style={{ @@ -348,3 +351,4 @@ export function AddTorrentModal({ open, onClose }: Props) { ) } + diff --git a/src/components/ContextMenu.tsx b/src/components/ContextMenu.tsx index 87a212d..e1aea3d 100644 --- a/src/components/ContextMenu.tsx +++ b/src/components/ContextMenu.tsx @@ -1,5 +1,7 @@ import { useState, useRef, useEffect } from 'react' import { ChevronRight } from 'lucide-react' +import { PathInput } from './ui/PathInput' +import { usePathHistory } from '../hooks/usePathHistory' import { useCategories, useTags, @@ -34,6 +36,7 @@ export function ContextMenu({ x, y, torrents, onClose }: Props) { const [inputValue, setInputValue] = useState('') const ref = useRef(null) const inputRef = useRef(null) + const { addPath } = usePathHistory() const { data: categories = {} } = useCategories() const { data: tags = [] } = useTags() @@ -135,13 +138,13 @@ export function ContextMenu({ x, y, torrents, onClose }: Props) { } if (editorMode === 'savePath') { - setLocationMutation.mutate({ hashes, location: value }) + setLocationMutation.mutate({ hashes, location: value }, { onSuccess: () => addPath(value) }) onClose() return } if (editorMode === 'downloadPath') { - setDownloadPathMutation.mutate({ hashes, downloadPath: value }) + setDownloadPathMutation.mutate({ hashes, downloadPath: value }, { onSuccess: () => addPath(value) }) onClose() } } @@ -198,19 +201,36 @@ export function ContextMenu({ x, y, torrents, onClose }: Props) {
{editorTitle}
- setInputValue(e.target.value)} - placeholder={editorPlaceholder} - onKeyDown={(e) => { - if (e.key === 'Enter') handleEditorSubmit() - if (e.key === 'Escape') onClose() - }} - className="w-full px-3 py-2 rounded-lg border text-sm mb-2" - style={{ backgroundColor: 'var(--bg-secondary)', borderColor: 'var(--border)', color: 'var(--text-primary)' }} - /> + {editorMode === 'rename' ? ( + setInputValue(e.target.value)} + placeholder={editorPlaceholder} + onKeyDown={(e) => { + if (e.key === 'Enter') handleEditorSubmit() + if (e.key === 'Escape') onClose() + }} + className="w-full px-3 py-2 rounded-lg border text-sm mb-2" + style={{ backgroundColor: 'var(--bg-secondary)', borderColor: 'var(--border)', color: 'var(--text-primary)' }} + /> + ) : ( +
+ { + if (e.key === 'Enter') handleEditorSubmit() + if (e.key === 'Escape') onClose() + }} + className="w-full px-3 py-2 rounded-lg border text-sm" + style={{ backgroundColor: 'var(--bg-secondary)', borderColor: 'var(--border)', color: 'var(--text-primary)' }} + /> +
+ )}