fix(plugin): use correct SteamClient API, alwaysRender true, wrap stop in try-catch
This commit is contained in:
@@ -42,21 +42,15 @@ function Content() {
|
||||
// ── Register SteamClient game events ──────────────────────────
|
||||
useEffect(() => {
|
||||
try {
|
||||
const startedReg = SteamClient.Apps.RegisterForGameStarted(async (appId: number) => {
|
||||
let gameName = `App ${appId}`
|
||||
try {
|
||||
const info = await SteamClient.Apps.GetCurrentGameInfo()
|
||||
if (info.appId === appId) {
|
||||
gameName = info.strAppName
|
||||
}
|
||||
} catch {
|
||||
// GetCurrentGameInfo may not be available in all contexts
|
||||
}
|
||||
onGameStart(appId, gameName)
|
||||
})
|
||||
const startedReg = SteamClient.Apps.RegisterForGameActionStart(
|
||||
(_gameActionId: number, appId: string, _action: string, _source: number) => {
|
||||
const appIdNum = parseInt(appId, 10)
|
||||
onGameStart(appIdNum, `App ${appId}`)
|
||||
},
|
||||
)
|
||||
gameStartedUnregRef.current = startedReg
|
||||
|
||||
const stoppedReg = SteamClient.Apps.RegisterForGameStopped((_appId: number) => {
|
||||
const stoppedReg = SteamClient.Apps.RegisterForGameActionEnd((_gameActionId: number) => {
|
||||
onGameStop()
|
||||
})
|
||||
gameStoppedUnregRef.current = stoppedReg
|
||||
@@ -83,13 +77,13 @@ function Content() {
|
||||
|
||||
// ── Handle stop recording: parse log + read system info ────────
|
||||
async function handleStop() {
|
||||
try {
|
||||
stopRecording()
|
||||
|
||||
// Parse the MangoHud log
|
||||
const logResult = await readAndParseMangohudLog()
|
||||
if (logResult.error) {
|
||||
setError(logResult.error)
|
||||
// Still transition to stopped state so user can see the error + manual fields
|
||||
return
|
||||
}
|
||||
|
||||
@@ -102,13 +96,18 @@ function Content() {
|
||||
// Read Proton version + launch options if we have an app ID
|
||||
let protonVersion = ""
|
||||
let launchOptions = ""
|
||||
if (session.appId) {
|
||||
const currentAppId = session.appId
|
||||
if (currentAppId) {
|
||||
try {
|
||||
const [pv, lo] = await Promise.all([
|
||||
getProtonVersion(session.appId),
|
||||
getLaunchOptions(session.appId),
|
||||
getProtonVersion(currentAppId),
|
||||
getLaunchOptions(currentAppId),
|
||||
])
|
||||
protonVersion = pv
|
||||
launchOptions = lo
|
||||
} catch {
|
||||
// Non-critical, continue without
|
||||
}
|
||||
}
|
||||
|
||||
// Use settings hardware override if set, otherwise auto-detected
|
||||
@@ -126,6 +125,10 @@ function Content() {
|
||||
protonVersion,
|
||||
launchOptions,
|
||||
})
|
||||
} catch (e) {
|
||||
console.error("[DeckyVault] Error stopping recording:", e)
|
||||
setError("Failed to process recording. Check the MangoHud log.")
|
||||
}
|
||||
}
|
||||
|
||||
if (!loaded) {
|
||||
@@ -215,7 +218,7 @@ export default definePlugin(() => {
|
||||
titleView: <div className={staticClasses.Title}>DeckyVault</div>,
|
||||
content: <Content />,
|
||||
icon: <DeckyVaultIcon />,
|
||||
alwaysRender: false,
|
||||
alwaysRender: true,
|
||||
onDismount() {
|
||||
console.log("[DeckyVault] Plugin unloading")
|
||||
},
|
||||
|
||||
Vendored
+4
-8
@@ -5,16 +5,12 @@
|
||||
declare global {
|
||||
const SteamClient: {
|
||||
Apps: {
|
||||
RegisterForGameStarted: (
|
||||
callback: (appId: number) => void,
|
||||
RegisterForGameActionStart: (
|
||||
callback: (gameActionId: number, appId: string, action: string, source: number) => void,
|
||||
) => { unregister: () => void }
|
||||
RegisterForGameStopped: (
|
||||
callback: (appId: number) => void,
|
||||
RegisterForGameActionEnd: (
|
||||
callback: (gameActionId: number) => void,
|
||||
) => { unregister: () => void }
|
||||
GetCurrentGameInfo: () => Promise<{
|
||||
appId: number
|
||||
strAppName: string
|
||||
}>
|
||||
}
|
||||
System: {
|
||||
GetOSVersion: () => Promise<string>
|
||||
|
||||
Reference in New Issue
Block a user