From fb3d3d4d3414394237cc9d664d65c14be179927f Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Fri, 18 Jul 2025 20:59:47 -0400 Subject: add nerd stuff modal with dll details --- src/components/NerdStuffModal.tsx | 95 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/components/NerdStuffModal.tsx (limited to 'src/components/NerdStuffModal.tsx') diff --git a/src/components/NerdStuffModal.tsx b/src/components/NerdStuffModal.tsx new file mode 100644 index 0000000..4dd53b1 --- /dev/null +++ b/src/components/NerdStuffModal.tsx @@ -0,0 +1,95 @@ +import { useState, useEffect } from "react"; +import { + ModalRoot, + Field, + Focusable +} from "@decky/ui"; +import { getDllStats, DllStatsResult } from "../api/lsfgApi"; + +interface NerdStuffModalProps { + closeModal?: () => void; +} + +export function NerdStuffModal({ closeModal }: NerdStuffModalProps) { + const [dllStats, setDllStats] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + const loadDllStats = async () => { + try { + setLoading(true); + setError(null); + const result = await getDllStats(); + setDllStats(result); + } catch (err) { + setError(err instanceof Error ? err.message : "Failed to load DLL stats"); + } finally { + setLoading(false); + } + }; + + loadDllStats(); + }, []); + + const formatSHA256 = (hash: string) => { + // Format SHA256 hash for better readability (add spaces every 8 characters) + return hash.replace(/(.{8})/g, '$1 ').trim(); + }; + + const copyToClipboard = async (text: string) => { + try { + await navigator.clipboard.writeText(text); + // Could add a toast notification here if desired + } catch (err) { + console.error("Failed to copy to clipboard:", err); + } + }; + + return ( + + {loading && ( +
Loading DLL information...
+ )} + + {error && ( +
Error: {error}
+ )} + + {!loading && !error && dllStats && ( + <> + {!dllStats.success ? ( +
{dllStats.error || "Failed to get DLL stats"}
+ ) : ( +
+ + dllStats.dll_path && copyToClipboard(dllStats.dll_path)} + onActivate={() => dllStats.dll_path && copyToClipboard(dllStats.dll_path)} + > + {dllStats.dll_path || "Not available"} + + + + + dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)} + onActivate={() => dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)} + > + {dllStats.dll_sha256 ? formatSHA256(dllStats.dll_sha256) : "Not available"} + + + + {dllStats.dll_source && ( + +
{dllStats.dll_source}
+
+ )} + +
+ )} + + )} +
+ ); +} -- cgit v1.2.3