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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
import { useEffect } from "react";
import { PanelSection, showModal, ButtonItem, PanelSectionRow } from "@decky/ui";
import { useInstallationStatus, useDllDetection, useLsfgConfig } from "../hooks/useLsfgHooks";
import { useProfileManagement } from "../hooks/useProfileManagement";
import { useInstallationActions } from "../hooks/useInstallationActions";
import { StatusDisplay } from "./StatusDisplay";
import { InstallationButton } from "./InstallationButton";
import { ConfigurationSection } from "./ConfigurationSection";
import { ProfileManagement } from "./ProfileManagement";
import { UsageInstructions } from "./UsageInstructions";
import { WikiButton } from "./WikiButton";
import { ClipboardButton } from "./ClipboardButton";
import { SmartClipboardButton } from "./SmartClipboardButton";
import { FgmodClipboardButton } from "./FgmodClipboardButton";
// import { ClipboardDisplay } from "./ClipboardDisplay";
// import { PluginUpdateChecker } from "./PluginUpdateChecker";
import { NerdStuffModal } from "./NerdStuffModal";
import FlatpaksModal from "./FlatpaksModal";
import { ConfigurationData } from "../config/configSchema";
export function Content() {
const {
isInstalled,
installationStatus,
setIsInstalled,
setInstallationStatus
} = useInstallationStatus();
const { dllDetected, dllDetectionStatus } = useDllDetection();
const {
config,
loadLsfgConfig,
updateField
} = useLsfgConfig();
const {
currentProfile,
updateProfileConfig,
loadProfiles
} = useProfileManagement();
const { isInstalling, isUninstalling, handleInstall, handleUninstall } = useInstallationActions();
// Reload config when installation status changes
useEffect(() => {
if (isInstalled) {
loadLsfgConfig();
}
}, [isInstalled, loadLsfgConfig]);
// Generic configuration change handler
const handleConfigChange = async (fieldName: keyof ConfigurationData, value: boolean | number | string) => {
// If we have a current profile, update that profile specifically
if (currentProfile) {
const newConfig = { ...config, [fieldName]: value };
const result = await updateProfileConfig(currentProfile, newConfig);
if (result.success) {
// Reload config to reflect the changes from the backend
await loadLsfgConfig();
}
} else {
// Fallback to the original method for backward compatibility
await updateField(fieldName, value);
}
};
const onInstall = () => {
handleInstall(setIsInstalled, setInstallationStatus, loadLsfgConfig);
};
const onUninstall = () => {
handleUninstall(setIsInstalled, setInstallationStatus);
};
const handleShowNerdStuff = () => {
showModal(<NerdStuffModal />);
};
const handleShowFlatpaks = () => {
showModal(<FlatpaksModal />);
};
return (
<PanelSection>
{/* Show installation components at top when not fully installed */}
{!isInstalled && (
<>
<InstallationButton
isInstalled={isInstalled}
isInstalling={isInstalling}
isUninstalling={isUninstalling}
onInstall={onInstall}
onUninstall={onUninstall}
/>
<StatusDisplay
dllDetected={dllDetected}
dllDetectionStatus={dllDetectionStatus}
isInstalled={isInstalled}
installationStatus={installationStatus}
/>
</>
)}
{/* Clipboard buttons - only show if installed */}
{isInstalled && (
<>
{/* <ClipboardDisplay /> */}
<SmartClipboardButton />
<FgmodClipboardButton />
</>
)}
{/* Profile Management - only show if installed */}
{isInstalled && (
<ProfileManagement
currentProfile={currentProfile}
onProfileChange={async () => {
await loadProfiles();
await loadLsfgConfig();
}}
/>
)}
{/* Configuration Section - only show if installed */}
{isInstalled && (
<ConfigurationSection
config={config}
onConfigChange={handleConfigChange}
/>
)}
{/* Usage instructions - always visible for user guidance */}
<UsageInstructions config={config} />
{/* Wiki and clipboard buttons - always available for documentation */}
<WikiButton />
<ClipboardButton />
{/* Plugin Update Checker */}
{/* <PluginUpdateChecker /> */}
{/* Show installation components at bottom when fully installed */}
{isInstalled && (
<>
<InstallationButton
isInstalled={isInstalled}
isInstalling={isInstalling}
isUninstalling={isUninstalling}
onInstall={onInstall}
onUninstall={onUninstall}
/>
<StatusDisplay
dllDetected={dllDetected}
dllDetectionStatus={dllDetectionStatus}
isInstalled={isInstalled}
installationStatus={installationStatus}
/>
</>
)}
{/* Nerd Stuff Button */}
<PanelSectionRow>
<ButtonItem
layout="below"
onClick={handleShowNerdStuff}
>
Nerd Stuff
</ButtonItem>
</PanelSectionRow>
{/* Flatpaks Button */}
<PanelSectionRow>
<ButtonItem
layout="below"
onClick={handleShowFlatpaks}
>
Flatpaks
</ButtonItem>
</PanelSectionRow>
</PanelSection>
);
}
|