diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-21 23:15:29 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-21 23:15:29 -0400 |
| commit | 4112393b17d25e54f1b8822734210b045da97613 (patch) | |
| tree | 7fd335fb69fc7bf2260acd72a505ae5476bbd6b6 /src/hooks | |
| parent | e54b7e2c5f3a736f248353317007f922771ab0c7 (diff) | |
| download | decky-lsfg-vk-4112393b17d25e54f1b8822734210b045da97613.tar.gz decky-lsfg-vk-4112393b17d25e54f1b8822734210b045da97613.zip | |
dry up with py generators for ts backends
Diffstat (limited to 'src/hooks')
| -rw-r--r-- | src/hooks/useInstallationActions.ts | 37 | ||||
| -rw-r--r-- | src/hooks/useLsfgHooks.ts | 15 |
2 files changed, 18 insertions, 34 deletions
diff --git a/src/hooks/useInstallationActions.ts b/src/hooks/useInstallationActions.ts index 8dcf831..18de6b5 100644 --- a/src/hooks/useInstallationActions.ts +++ b/src/hooks/useInstallationActions.ts @@ -1,6 +1,11 @@ import { useState } from "react"; -import { toaster } from "@decky/api"; import { installLsfgVk, uninstallLsfgVk } from "../api/lsfgApi"; +import { + showInstallSuccessToast, + showInstallErrorToast, + showUninstallSuccessToast, + showUninstallErrorToast +} from "../utils/toastUtils"; export function useInstallationActions() { const [isInstalling, setIsInstalling] = useState<boolean>(false); @@ -19,10 +24,7 @@ export function useInstallationActions() { if (result.success) { setIsInstalled(true); setInstallationStatus("lsfg-vk installed successfully!"); - toaster.toast({ - title: "Installation Complete", - body: "lsfg-vk has been installed successfully" - }); + showInstallSuccessToast(); // Reload lsfg config after installation if (reloadConfig) { @@ -30,17 +32,11 @@ export function useInstallationActions() { } } else { setInstallationStatus(`Installation failed: ${result.error}`); - toaster.toast({ - title: "Installation Failed", - body: result.error || "Unknown error occurred" - }); + showInstallErrorToast(result.error); } } catch (error) { setInstallationStatus(`Installation failed: ${error}`); - toaster.toast({ - title: "Installation Failed", - body: `Error: ${error}` - }); + showInstallErrorToast(String(error)); } finally { setIsInstalling(false); } @@ -58,23 +54,14 @@ export function useInstallationActions() { if (result.success) { setIsInstalled(false); setInstallationStatus("lsfg-vk uninstalled successfully!"); - toaster.toast({ - title: "Uninstallation Complete", - body: result.message || "lsfg-vk has been uninstalled successfully" - }); + showUninstallSuccessToast(); } else { setInstallationStatus(`Uninstallation failed: ${result.error}`); - toaster.toast({ - title: "Uninstallation Failed", - body: result.error || "Unknown error occurred" - }); + showUninstallErrorToast(result.error); } } catch (error) { setInstallationStatus(`Uninstallation failed: ${error}`); - toaster.toast({ - title: "Uninstallation Failed", - body: `Error: ${error}` - }); + showUninstallErrorToast(String(error)); } finally { setIsUninstalling(false); } diff --git a/src/hooks/useLsfgHooks.ts b/src/hooks/useLsfgHooks.ts index e514d72..e5dea63 100644 --- a/src/hooks/useLsfgHooks.ts +++ b/src/hooks/useLsfgHooks.ts @@ -1,5 +1,4 @@ import { useState, useEffect, useCallback } from "react"; -import { toaster } from "@decky/api"; import { checkLsfgVkInstalled, checkLosslessScalingDll, @@ -8,6 +7,7 @@ import { type ConfigUpdateResult } from "../api/lsfgApi"; import { ConfigurationData, ConfigurationManager } from "../config/configSchema"; +import { showErrorToast, ToastMessages } from "../utils/toastUtils"; export function useInstallationStatus() { const [isInstalled, setIsInstalled] = useState<boolean>(false); @@ -95,17 +95,14 @@ export function useLsfgConfig() { if (result.success) { setConfig(newConfig); } else { - toaster.toast({ - title: "Update Failed", - body: result.error || "Failed to update configuration" - }); + showErrorToast( + ToastMessages.CONFIG_UPDATE_ERROR.title, + result.error || ToastMessages.CONFIG_UPDATE_ERROR.body + ); } return result; } catch (error) { - toaster.toast({ - title: "Update Failed", - body: `Error: ${error}` - }); + showErrorToast(ToastMessages.CONFIG_UPDATE_ERROR.title, String(error)); return { success: false, error: String(error) }; } }, []); |
