diff options
| author | Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> | 2025-07-22 00:17:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-22 00:17:50 -0400 |
| commit | 4fee88babae0dc69a332480c3e491500dab64d7c (patch) | |
| tree | 2e9ee6360337978e9264173a2e20daf5ec195393 /src/components | |
| parent | 2106ef8eb31ee46611fce07dd715d3ac1c4ca0ab (diff) | |
| parent | e83f026b0d1edf5a7ee1477f4b10eb574f506f95 (diff) | |
| download | decky-lsfg-vk-4fee88babae0dc69a332480c3e491500dab64d7c.tar.gz decky-lsfg-vk-4fee88babae0dc69a332480c3e491500dab64d7c.zip | |
Merge pull request #63 from xXJSONDeruloXx/cleanup-jul21
refactor: remove unused backend files and improve configuration handl…
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/SmartClipboardButton.tsx | 71 | ||||
| -rw-r--r-- | src/components/UsageInstructions.tsx | 22 | ||||
| -rw-r--r-- | src/components/index.ts | 2 |
3 files changed, 12 insertions, 83 deletions
diff --git a/src/components/SmartClipboardButton.tsx b/src/components/SmartClipboardButton.tsx index 81223bd..098b53d 100644 --- a/src/components/SmartClipboardButton.tsx +++ b/src/components/SmartClipboardButton.tsx @@ -1,8 +1,9 @@ import { useState } from "react"; import { PanelSectionRow, ButtonItem } from "@decky/ui"; import { FaClipboard } from "react-icons/fa"; -import { toaster } from "@decky/api"; import { getLaunchOption } from "../api/lsfgApi"; +import { showClipboardSuccessToast, showClipboardErrorToast, showSuccessToast } from "../utils/toastUtils"; +import { copyWithVerification } from "../utils/clipboardUtils"; export function SmartClipboardButton() { const [isLoading, setIsLoading] = useState(false); @@ -22,72 +23,20 @@ export function SmartClipboardButton() { setIsLoading(true); try { const text = await getLaunchOptionText(); + const { success, verified } = await copyWithVerification(text); - // Use the proven input simulation method - const tempInput = document.createElement('input'); - tempInput.value = text; - tempInput.style.position = 'absolute'; - tempInput.style.left = '-9999px'; - document.body.appendChild(tempInput); - - // Focus and select the text - tempInput.focus(); - tempInput.select(); - - // Try copying using execCommand first (most reliable in gaming mode) - let copySuccess = false; - try { - if (document.execCommand('copy')) { - copySuccess = true; - } - } catch (e) { - // If execCommand fails, try navigator.clipboard as fallback - try { - await navigator.clipboard.writeText(text); - copySuccess = true; - } catch (clipboardError) { - console.error('Both copy methods failed:', e, clipboardError); - } - } - - // Clean up - document.body.removeChild(tempInput); - - if (copySuccess) { - // Verify the copy worked by reading back - try { - const readBack = await navigator.clipboard.readText(); - if (readBack === text) { - toaster.toast({ - title: "Copied to Clipboard!", - body: "Launch option ready to paste" - }); - } else { - // Copy worked but verification failed - still consider it success - toaster.toast({ - title: "Copied to Clipboard!", - body: "Launch option copied (verification unavailable)" - }); - } - } catch (e) { - // Verification failed but copy likely worked - toaster.toast({ - title: "Copied to Clipboard!", - body: "Launch option copied successfully" - }); + if (success) { + if (verified) { + showClipboardSuccessToast(); + } else { + showSuccessToast("Copied to Clipboard!", "Launch option copied (verification unavailable)"); } } else { - toaster.toast({ - title: "Copy Failed", - body: "Unable to copy to clipboard" - }); + showClipboardErrorToast(); } } catch (error) { - toaster.toast({ - title: "Copy Failed", - body: `Error: ${String(error)}` - }); + showClipboardErrorToast(); } finally { setIsLoading(false); } diff --git a/src/components/UsageInstructions.tsx b/src/components/UsageInstructions.tsx index bcf258b..0c27517 100644 --- a/src/components/UsageInstructions.tsx +++ b/src/components/UsageInstructions.tsx @@ -5,7 +5,7 @@ interface UsageInstructionsProps { config: ConfigurationData; } -export function UsageInstructions({ config }: UsageInstructionsProps) { +export function UsageInstructions({ config: _config }: UsageInstructionsProps) { return ( <> <PanelSectionRow> @@ -56,26 +56,6 @@ export function UsageInstructions({ config }: UsageInstructionsProps) { </div> </PanelSectionRow> - {/* <PanelSectionRow> - <div - style={{ - fontSize: "12px", - lineHeight: "1.4", - opacity: "0.8", - whiteSpace: "pre-wrap" - }} - > - {`Current Configuration: -• DLL Path: ${config.dll} -• Multiplier: ${config.multiplier}x -• Flow Scale: ${Math.round(config.flow_scale * 100)}% -• Performance Mode: ${config.performance_mode ? "Yes" : "No"} -• HDR Mode: ${config.hdr_mode ? "Yes" : "No"} -• Present Mode: ${config.experimental_present_mode || "FIFO (VSync)"} -• DXVK Frame Rate: ${config.dxvk_frame_rate > 0 ? `${config.dxvk_frame_rate} FPS` : "Off"}`} - </div> - </PanelSectionRow> */} - <PanelSectionRow> <div style={{ diff --git a/src/components/index.ts b/src/components/index.ts index 682598c..e4568f1 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -2,7 +2,7 @@ export { Content } from "./Content"; export { StatusDisplay } from "./StatusDisplay"; export { InstallationButton } from "./InstallationButton"; export { ConfigurationSection } from "./ConfigurationSection"; -// export { UsageInstructions } from "./UsageInstructions"; +export { UsageInstructions } from "./UsageInstructions"; export { WikiButton } from "./WikiButton"; export { SmartClipboardButton } from "./SmartClipboardButton"; export { LaunchOptionInfo } from "./LaunchOptionInfo"; |
