fix: limit trade flow to 20 rows

This commit is contained in:
root 2026-02-28 10:16:38 +00:00
parent 0ac2225979
commit 5cf2003ca7

View File

@ -73,8 +73,8 @@ function LiveTrades({ symbol }: { symbol: Symbol }) {
const existingIds = new Set(prev.map((t: TradeRow) => t.agg_id)); const existingIds = new Set(prev.map((t: TradeRow) => t.agg_id));
const newOnes = incoming.filter((t: TradeRow) => !existingIds.has(t.agg_id)); const newOnes = incoming.filter((t: TradeRow) => !existingIds.has(t.agg_id));
if (newOnes.length === 0) return prev; if (newOnes.length === 0) return prev;
// 最新在顶部,最多保留50条 // 最新在顶部,最多保留20条
return [...newOnes, ...prev].slice(0, 50); return [...newOnes, ...prev].slice(0, 20);
}); });
setLoading(false); setLoading(false);
} catch {} } catch {}