From 89e64a7dbddb8f713dd2ca37131924e8bd8ab51f Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Sat, 5 Sep 2026 23:58:16 -0400 Subject: feat: select Lossless Scaling lsfg-vk branch --- src/hooks/useLsfgHooks.ts | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'src/hooks') diff --git a/src/hooks/useLsfgHooks.ts b/src/hooks/useLsfgHooks.ts index 597110e..dfbf2cd 100644 --- a/src/hooks/useLsfgHooks.ts +++ b/src/hooks/useLsfgHooks.ts @@ -2,8 +2,12 @@ import { useState, useEffect, useCallback } from "react"; import { checkLsfgVkInstalled, getLsfgConfig, + getLosslessScalingBranchStatus, + selectLosslessScalingBranch, updateLsfgConfigFromObject, - type ConfigUpdateResult + type ConfigUpdateResult, + type SteamBranchOperationResult, + type SteamBranchStatus } from "../api/lsfgApi"; import { ConfigurationData, getDefaults } from "../config/configSchema"; import { showErrorToast, ToastMessages } from "../utils/toastUtils"; @@ -13,8 +17,17 @@ export function useInstallationStatus() { const [installationStatus, setInstallationStatus] = useState(""); const [losslessScalingInstalled, setLosslessScalingInstalled] = useState(false); const [losslessScalingStatus, setLosslessScalingStatus] = useState(""); + const [steamBranchStatus, setSteamBranchStatus] = useState(null); + const [isSwitchingSteamBranch, setIsSwitchingSteamBranch] = useState(false); const checkInstallation = async () => { + try { + setSteamBranchStatus(await getLosslessScalingBranchStatus()); + } catch (error) { + console.error("Error checking Lossless Scaling Steam branch:", error); + setSteamBranchStatus(null); + } + try { const status = await checkLsfgVkInstalled(); setIsInstalled(status.installed); @@ -27,6 +40,7 @@ export function useInstallationStatus() { } return status.installed; } catch (error) { + setSteamBranchStatus(null); setLosslessScalingInstalled(false); setLosslessScalingStatus("Lossless Scaling Not Installed"); setInstallationStatus("lsfg-vk Not Installed"); @@ -34,6 +48,33 @@ export function useInstallationStatus() { } }; + const selectLosslessScalingBranchForUser = async (): Promise => { + setIsSwitchingSteamBranch(true); + try { + const result = await selectLosslessScalingBranch(); + setSteamBranchStatus(result); + return result; + } catch (error) { + const result: SteamBranchOperationResult = { + success: false, + message: "", + error: String(error), + installed: false, + manifest_path: undefined, + selected_branch: undefined, + current_branch: undefined, + target_branch: "lsfg-vk", + needs_switch: false, + restart_required: false, + changed: false + }; + setSteamBranchStatus(result); + return result; + } finally { + setIsSwitchingSteamBranch(false); + } + }; + useEffect(() => { checkInstallation(); }, []); @@ -45,6 +86,9 @@ export function useInstallationStatus() { setInstallationStatus, losslessScalingInstalled, losslessScalingStatus, + steamBranchStatus, + isSwitchingSteamBranch, + selectLosslessScalingBranch: selectLosslessScalingBranchForUser, checkInstallation }; } -- cgit v1.2.3