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")); }