diff --git a/client/src/pages/EQPage.tsx b/client/src/pages/EQPage.tsx index 3a68f58..ac16ea3 100644 --- a/client/src/pages/EQPage.tsx +++ b/client/src/pages/EQPage.tsx @@ -520,6 +520,8 @@ function FreqChart({ /* ── Main Component ── */ +const rawCurveCache = new Map(); + export default function EQPage() { const [, setLocation] = useLocation(); const { @@ -610,6 +612,7 @@ export default function EQPage() { const [isConfirmingTarget, setIsConfirmingTarget] = useState(false); const [currentRawCurve, setCurrentRawCurve] = useState(null); const [rawCurveLoading, setRawCurveLoading] = useState(false); + const rawCurveCacheRef = useRef(rawCurveCache); const allowPeqRemoteSyncRef = useRef(false); const lastPeqCatalogSyncKeyRef = useRef(""); const syncingHeadphoneRef = useRef(false); @@ -1219,6 +1222,17 @@ export default function EQPage() { const model = peq?.model?.trim() ?? ""; if (!brand || !model) return null; + const cacheKey = `${brand}|${model}`; + if (rawCurveCacheRef.current.has(cacheKey)) { + const cached = rawCurveCacheRef.current.get(cacheKey); + if (cached) { + console.log("[modelCurve] cache hit", { brand, model, rawLength: cached.length }); + } else { + console.log("[modelCurve] cache hit (no raw)", { brand, model }); + } + return cached ?? null; + } + const modelCurve = await getModelCurve(brand, model); if (modelCurve && typeof modelCurve === "object") { const payload = modelCurve as { @@ -1244,6 +1258,7 @@ export default function EQPage() { }) : null; const cleanedRaw = raw && raw.every((v) => Number.isFinite(v)) ? (raw as number[]) : null; + rawCurveCacheRef.current.set(cacheKey, cleanedRaw); console.log("[modelCurve] raw check", { brand, model,