fix(frontend): подготовка к прому

This commit is contained in:
2025-12-29 01:25:25 +03:00
parent 799a11b86d
commit 5e0f22e39e
6 changed files with 39 additions and 9 deletions

View File

@@ -34,7 +34,7 @@ const WINDOW_OPTIONS_MS = [15_000, 30_000, 60_000, 120_000, 300_000] as const;
const DEFAULT_WINDOW_MS = 60_000;
const MIN_HZ = 0.1;
const MAX_HZ = 60;
// const MAX_HZ = 60;
const DEFAULT_REQUESTED_HZ = 10;
// If there are more than 600 points in selected window -> downsample
@@ -56,7 +56,7 @@ let flushTimer: number | null = null;
let lastSeenSample: AudioSample | null = null;
function clampInt(v: number, min: number, max: number): number {
function clampInt(v: number, min: number): number {
if (!Number.isFinite(v)) return min;
return Math.max(min, v);
}
@@ -68,7 +68,7 @@ function isAllowedWindowMs(
}
function buildWsUrl(base: string, hz: number): string {
const safeHz = clampInt(hz, MIN_HZ, MAX_HZ);
const safeHz = clampInt(hz, MIN_HZ);
// Prefer URL() for correctness (keeps existing params)
try {
@@ -188,7 +188,7 @@ export const useLiveStreamStore = create<LiveStreamState>()((set, get) => {
requestedHz: DEFAULT_REQUESTED_HZ,
setRequestedHz: (hz) => {
const next = clampInt(hz, MIN_HZ, MAX_HZ);
const next = clampInt(hz, MIN_HZ);
const prev = get().requestedHz;
if (next === prev) return;
@@ -223,7 +223,7 @@ export const useLiveStreamStore = create<LiveStreamState>()((set, get) => {
},
loadLatest: async (limit = 300) => {
const safeLimit = clampInt(limit, 1, 5000);
const safeLimit = clampInt(limit, 1);
const base = env.apiUrl.replace(/\/$/, "");
const url = `${base}/api/v1/audio/latest?limit=${safeLimit}`;