diff --git a/frontend/src/components/DownloadCenter.tsx b/frontend/src/components/DownloadCenter.tsx index a423692..6adb61b 100644 --- a/frontend/src/components/DownloadCenter.tsx +++ b/frontend/src/components/DownloadCenter.tsx @@ -27,6 +27,7 @@ const ShareDialog = lazy(() => import("./ShareDialog")); import { useConfirm } from "./ConfirmProvider"; import { useLiveQuery } from "../lib/useLiveQuery"; import { api, type DownloadJob, type Me } from "../lib/api"; +import { invalidateDownloads } from "../lib/downloads"; import { notify } from "../lib/notifications"; import { formatBytes, formatDuration, formatEta, formatSpeed } from "../lib/format"; @@ -546,7 +547,7 @@ export default function DownloadCenter({ me }: { me: Me }) { const [addUrl, setAddUrl] = useState(""); const [addSource, setAddSource] = useState(null); const [manage, setManage] = useState(false); - const [renameJob, setRenameJob] = useState(null); + const [metaJob, setMetaJob] = useState(null); const [shareJob, setShareJob] = useState(null); const [editJob, setEditJob] = useState(null); @@ -556,11 +557,7 @@ export default function DownloadCenter({ me }: { me: Me }) { const queue = jobs.filter((j) => ["queued", "running", "paused", "error"].includes(j.status)); const library = jobs.filter((j) => j.status === "done"); - const invalidate = () => { - qc.invalidateQueries({ queryKey: ["downloads"] }); - qc.invalidateQueries({ queryKey: ["download-index"] }); - qc.invalidateQueries({ queryKey: ["download-usage"] }); - }; + const invalidate = () => invalidateDownloads(qc); const act = useMutation({ mutationFn: ({ id, op }: { id: number; op: "pause" | "resume" | "cancel" | "delete" }) => op === "pause" ? api.pauseDownload(id) @@ -674,7 +671,7 @@ export default function DownloadCenter({ me }: { me: Me }) { )} - setRenameJob(job)} title={t("downloads.actions.editDetails")}> + setMetaJob(job)} title={t("downloads.actions.editDetails")}> setShareJob(job)} title={t("downloads.actions.share")}> @@ -738,7 +735,7 @@ export default function DownloadCenter({ me }: { me: Me }) { /> )} {manage && setManage(false)} />} - {renameJob && setRenameJob(null)} />} + {metaJob && setMetaJob(null)} />} {shareJob && setShareJob(null)} />} {editJob && setEditJob(null)} />} diff --git a/frontend/src/components/DownloadDialog.tsx b/frontend/src/components/DownloadDialog.tsx index 6c9e87b..70c7b54 100644 --- a/frontend/src/components/DownloadDialog.tsx +++ b/frontend/src/components/DownloadDialog.tsx @@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import Modal from "./Modal"; import { api } from "../lib/api"; +import { invalidateDownloads } from "../lib/downloads"; // Lazy: the full profile editor only opens from the dialog's "manage presets" affordance. const ProfileEditor = lazy(() => import("./ProfileEditor")); @@ -43,9 +44,7 @@ export default function DownloadDialog({ profile_id: chosen, display_name: name.trim() || undefined, }); - qc.invalidateQueries({ queryKey: ["downloads"] }); - qc.invalidateQueries({ queryKey: ["download-index"] }); - qc.invalidateQueries({ queryKey: ["download-usage"] }); + invalidateDownloads(qc); notify({ level: "success", message: t("downloads.dialog.added"), diff --git a/frontend/src/i18n/locales/de/downloads.json b/frontend/src/i18n/locales/de/downloads.json index 83b0c2b..fd7b4c8 100644 --- a/frontend/src/i18n/locales/de/downloads.json +++ b/frontend/src/i18n/locales/de/downloads.json @@ -78,12 +78,6 @@ "copied": "Quell-Link in die Zwischenablage kopiert", "copyFailed": "Link konnte nicht kopiert werden" }, - "rename": { - "title": "Download umbenennen", - "label": "Anzeigename", - "hint": "Ändert nur den angezeigten und beim Speichern verwendeten Namen — die gespeicherte Datei behält ihren Namen.", - "save": "Speichern" - }, "edit": { "title": "Details bearbeiten", "name": "Titel", diff --git a/frontend/src/i18n/locales/en/downloads.json b/frontend/src/i18n/locales/en/downloads.json index 4e89fc9..0b404dc 100644 --- a/frontend/src/i18n/locales/en/downloads.json +++ b/frontend/src/i18n/locales/en/downloads.json @@ -78,12 +78,6 @@ "copied": "Source link copied to clipboard", "copyFailed": "Couldn't copy the link" }, - "rename": { - "title": "Rename download", - "label": "Display name", - "hint": "Only changes the name you see and download with — the stored file keeps its own name.", - "save": "Save" - }, "edit": { "title": "Edit details", "name": "Title", diff --git a/frontend/src/i18n/locales/hu/downloads.json b/frontend/src/i18n/locales/hu/downloads.json index a345960..b7e61de 100644 --- a/frontend/src/i18n/locales/hu/downloads.json +++ b/frontend/src/i18n/locales/hu/downloads.json @@ -78,12 +78,6 @@ "copied": "Forráslink a vágólapra másolva", "copyFailed": "Nem sikerült a link másolása" }, - "rename": { - "title": "Letöltés átnevezése", - "label": "Megjelenített név", - "hint": "Csak a megjelenített és letöltéskor használt nevet módosítja — a tárolt fájl neve nem változik.", - "save": "Mentés" - }, "edit": { "title": "Adatok szerkesztése", "name": "Cím", diff --git a/frontend/src/lib/downloads.ts b/frontend/src/lib/downloads.ts new file mode 100644 index 0000000..6fd9351 --- /dev/null +++ b/frontend/src/lib/downloads.ts @@ -0,0 +1,9 @@ +import type { QueryClient } from "@tanstack/react-query"; + +// The download queue, the per-card download index, and the storage-usage meter all move together +// whenever a job is enqueued, deleted, or its state changes — invalidate them as one unit. +export function invalidateDownloads(qc: QueryClient) { + qc.invalidateQueries({ queryKey: ["downloads"] }); + qc.invalidateQueries({ queryKey: ["download-index"] }); + qc.invalidateQueries({ queryKey: ["download-usage"] }); +}