fix(plugin): block no-FPS uploads and clamp FPS before submit

This commit is contained in:
2026-07-13 04:38:56 +08:00
parent bf33f8735d
commit a975497c16
2 changed files with 22 additions and 4 deletions
@@ -211,6 +211,10 @@ export default function SessionForm({
setError("No API key configured. Set one in the Settings tab.") setError("No API key configured. Set one in the Settings tab.")
return return
} }
if (session.fpsAvg == null || session.fpsAvg <= 0) {
setError("No FPS data captured. Re-record the session, or use Export to File only.")
return
}
setError("") setError("")
setUploadStatus("loading") setUploadStatus("loading")
setStatusMessage("Uploading entry…") setStatusMessage("Uploading entry…")
+18 -4
View File
@@ -235,6 +235,20 @@ export function useGameDetection(
return { detecting } return { detecting }
} }
// ── FPS Sanitizer ────────────────────────────────────────────────
const FPS_MAX = 1000
/** Clamp/cap an FPS value to [0, 1000]; return null for null/undefined/NaN. */
export function sanitizeFps(value: number | null | undefined): number | null {
if (value == null) return null
const n = Number(value)
if (isNaN(n)) return null
if (n < 0) return 0
if (n > FPS_MAX) return FPS_MAX
return n
}
// ── Payload Builder ───────────────────────────────────────────── // ── Payload Builder ─────────────────────────────────────────────
export function buildImportPayload(sess: SessionData): DeckyVaultImportV1 { export function buildImportPayload(sess: SessionData): DeckyVaultImportV1 {
@@ -242,10 +256,10 @@ export function buildImportPayload(sess: SessionData): DeckyVaultImportV1 {
version: 1, version: 1,
steamAppId: sess.appId ?? 0, steamAppId: sess.appId ?? 0,
hardwareSlug: sess.hardwareSlug, hardwareSlug: sess.hardwareSlug,
fpsAvg: sess.fpsAvg ?? 0, fpsAvg: sess.fpsAvg == null || sess.fpsAvg <= 0 ? 0 : sanitizeFps(sess.fpsAvg)!,
fpsLow: sess.fpsLow, fpsLow: sanitizeFps(sess.fpsLow),
fpsOnePercentLow: sess.fpsOnePercentLow, fpsOnePercentLow: sanitizeFps(sess.fpsOnePercentLow),
fpsHigh: sess.fpsHigh, fpsHigh: sanitizeFps(sess.fpsHigh),
protonVersion: sess.protonVersion || null, protonVersion: sess.protonVersion || null,
osVersion: sess.osVersion || null, osVersion: sess.osVersion || null,
versionString: sess.versionString || null, versionString: sess.versionString || null,