From fe3702c4b35b26d493f9960e154179e38b22d9ee Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Fri, 27 Mar 2026 09:28:28 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20refresh=20auto=20de=20la=20liste=20des?= =?UTF-8?q?=20t=C3=A9l=C3=A9chargements=20apr=C3=A8s=20ajout=20qBittorrent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le QbittorrentProvider expose un callback onDownloadStarted qui est appelé quand un téléchargement est lancé avec succès. Sur la page downloads, ce callback déclenche un refresh de la liste. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../app/(app)/downloads/DownloadsPage.tsx | 2 +- .../app/components/QbittorrentDownloadButton.tsx | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/backoffice/app/(app)/downloads/DownloadsPage.tsx b/apps/backoffice/app/(app)/downloads/DownloadsPage.tsx index d758754..53eb445 100644 --- a/apps/backoffice/app/(app)/downloads/DownloadsPage.tsx +++ b/apps/backoffice/app/(app)/downloads/DownloadsPage.tsx @@ -185,7 +185,7 @@ export function DownloadsPage({ initialDownloads, initialLatestFound, qbConfigur {/* Available downloads from latest detection */} {initialLatestFound.length > 0 && ( - + refresh(false)}>

diff --git a/apps/backoffice/app/components/QbittorrentDownloadButton.tsx b/apps/backoffice/app/components/QbittorrentDownloadButton.tsx index b6297f5..589fb18 100644 --- a/apps/backoffice/app/components/QbittorrentDownloadButton.tsx +++ b/apps/backoffice/app/components/QbittorrentDownloadButton.tsx @@ -4,9 +4,14 @@ import { useState, useEffect, createContext, useContext, type ReactNode } from " import { Icon } from "./ui"; import { useTranslation } from "@/lib/i18n/context"; -const QbConfigContext = createContext(false); +interface QbContextValue { + configured: boolean; + onDownloadStarted?: () => void; +} -export function QbittorrentProvider({ children, initialConfigured }: { children: ReactNode; initialConfigured?: boolean }) { +const QbConfigContext = createContext({ configured: false }); + +export function QbittorrentProvider({ children, initialConfigured, onDownloadStarted }: { children: ReactNode; initialConfigured?: boolean; onDownloadStarted?: () => void }) { const [configured, setConfigured] = useState(initialConfigured ?? false); useEffect(() => { @@ -20,7 +25,7 @@ export function QbittorrentProvider({ children, initialConfigured }: { children: .catch(() => setConfigured(false)); }, [initialConfigured]); - return {children}; + return {children}; } export function QbittorrentDownloadButton({ @@ -37,7 +42,7 @@ export function QbittorrentDownloadButton({ expectedVolumes?: number[]; }) { const { t } = useTranslation(); - const configured = useContext(QbConfigContext); + const { configured, onDownloadStarted } = useContext(QbConfigContext); const [sending, setSending] = useState(false); const [sent, setSent] = useState(false); const [error, setError] = useState(null); @@ -63,6 +68,7 @@ export function QbittorrentDownloadButton({ setError(data.error); } else if (data.success) { setSent(true); + onDownloadStarted?.(); } else { setError(data.message || t("prowlarr.sentError")); }