blob: 4a9a9f61ce970d209f95bcf5888ce2c604db370f (
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
|
import { definePlugin } from "@decky/api";
import { MdOutlineAutoAwesomeMotion } from "react-icons/md";
import { useState, useEffect } from "react";
import { OptiScalerControls } from "./components";
// import { InstalledGamesSection } from "./components/InstalledGamesSection";
import { checkFGModPath } from "./api";
import { safeAsyncOperation } from "./utils";
import { TIMEOUTS } from "./utils/constants";
type FgmodInfo = {
exists: boolean;
version?: string | null;
selected_fsr4_variant?: string | null;
selected_fsr4_variant_label?: string | null;
install_manifest_present?: boolean;
};
function MainContent() {
const [pathExists, setPathExists] = useState<boolean | null>(null);
const [fgmodInfo, setFgmodInfo] = useState<FgmodInfo | null>(null);
useEffect(() => {
const checkPath = async () => {
const result = await safeAsyncOperation(
async () => await checkFGModPath(),
'MainContent -> checkPath'
);
if (result) {
setFgmodInfo(result);
setPathExists(result.exists);
}
};
checkPath(); // Initial check
const intervalId = setInterval(checkPath, TIMEOUTS.pathCheck); // Check every 3 seconds
return () => clearInterval(intervalId); // Cleanup interval on component unmount
}, []);
return (
<>
<OptiScalerControls
pathExists={pathExists}
setPathExists={setPathExists}
fgmodInfo={fgmodInfo}
/>
{pathExists === true ? (
<>
{/* <InstalledGamesSection /> */}
</>
) : null}
</>
);
}
export default definePlugin(() => ({
name: "Decky Framegen",
titleView: <div>Decky Framegen</div>,
alwaysRender: true,
content: <MainContent />,
icon: <MdOutlineAutoAwesomeMotion />,
onDismount() {
console.log("Decky Framegen Plugin unmounted");
},
}));
|