blob: 4dd53b1d432f8258dc6fa9381c875d93a4d3cfa0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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<DllStatsResult | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(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 (
<ModalRoot onCancel={closeModal} onOK={closeModal}>
{loading && (
<div>Loading DLL information...</div>
)}
{error && (
<div>Error: {error}</div>
)}
{!loading && !error && dllStats && (
<>
{!dllStats.success ? (
<div>{dllStats.error || "Failed to get DLL stats"}</div>
) : (
<div>
<Field label="DLL Path">
<Focusable
onClick={() => dllStats.dll_path && copyToClipboard(dllStats.dll_path)}
onActivate={() => dllStats.dll_path && copyToClipboard(dllStats.dll_path)}
>
{dllStats.dll_path || "Not available"}
</Focusable>
</Field>
<Field label="SHA256 Hash">
<Focusable
onClick={() => dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)}
onActivate={() => dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)}
>
{dllStats.dll_sha256 ? formatSHA256(dllStats.dll_sha256) : "Not available"}
</Focusable>
</Field>
{dllStats.dll_source && (
<Field label="Detection Source">
<div>{dllStats.dll_source}</div>
</Field>
)}
</div>
)}
</>
)}
</ModalRoot>
);
}
|