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/useInstallationActions.ts | |
| 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/useInstallationActions.ts')
| -rw-r--r-- | src/hooks/useInstallationActions.ts | 37 |
1 files changed, 12 insertions, 25 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); } |
