From a79b129b0cc7e608834ca7c7df47ccef65052036 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Sat, 12 Apr 2025 00:03:37 +0200 Subject: [PATCH] Fix and refactor download buttons --- packages/web_ui/src/components/ModsPage.tsx | 73 +++++++++++---------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/packages/web_ui/src/components/ModsPage.tsx b/packages/web_ui/src/components/ModsPage.tsx index 868d8251..ab229010 100644 --- a/packages/web_ui/src/components/ModsPage.tsx +++ b/packages/web_ui/src/components/ModsPage.tsx @@ -176,6 +176,33 @@ function SearchModsButton() { const [sort, setSort] = useState("name"); const [sortOrder, setSortOrder] = useState<"asc" | "desc">("asc"); + // Function to handle download from Mod Portal to Controller + const handleControllerDownload = ( + modName: string, + modTitle: string | undefined, + modVersion: string | undefined, + portalFactorioVersion: FactorioVersion, + ) => { + if (modVersion) { + control.send( + new lib.ModPortalDownloadRequest( + modName, + modVersion, + portalFactorioVersion + ) + ).then(() => { + notification.success({ + message: "Download started", + description: `${modTitle || modName} v${ + modVersion + } is being downloaded to the controller.`, + }); + }).catch( + notifyErrorHandler("Error starting mod download") + ); + } + }; + // Fetch all mods from backend when modal opens or version changes useEffect(() => { if (!open || !factorioVersion) { @@ -408,22 +435,12 @@ function SearchModsButton() { {account.hasPermission("core.mod.download") && record.latest_release && (