429 에러 수정
This commit is contained in:
@@ -45,8 +45,10 @@ export interface UseMarketTickerOptions {
|
||||
}
|
||||
|
||||
const REST_POLL_INTERVAL = 30_000;
|
||||
const REST_POLL_LITE_MS = 60_000;
|
||||
const WS_BATCH_MS = 400;
|
||||
const FULL_LOAD_DEFER_MS = 2_000;
|
||||
const PRIORITY_DEBOUNCE_MS = 600;
|
||||
const WS_TICKER_CAP = 80;
|
||||
const LITE_BASE_MARKETS = ['KRW-BTC', 'KRW-USDT'];
|
||||
|
||||
@@ -196,14 +198,15 @@ export function useMarketTicker(opts: UseMarketTickerOptions = {}) {
|
||||
|
||||
const startPoll = useCallback((markets: string[]) => {
|
||||
clearPoll();
|
||||
if (markets.length === 0) return;
|
||||
if (markets.length === 0 || isMobileLite) return;
|
||||
const interval = isMobileLite ? REST_POLL_LITE_MS : REST_POLL_INTERVAL;
|
||||
pollTimerRef.current = setInterval(() => {
|
||||
if (!mountedRef.current) return;
|
||||
void fetchTickersThrottled(markets).then(raw => {
|
||||
if (raw.length > 0) applyRawList(raw);
|
||||
});
|
||||
}, REST_POLL_INTERVAL);
|
||||
}, [applyRawList, clearPoll]);
|
||||
}, interval);
|
||||
}, [applyRawList, clearPoll, isMobileLite]);
|
||||
|
||||
const loadTickersFor = useCallback(async (markets: string[]) => {
|
||||
const rawList = await fetchTickersThrottled(markets);
|
||||
@@ -280,12 +283,16 @@ export function useMarketTicker(opts: UseMarketTickerOptions = {}) {
|
||||
return () => clearTimeout(t);
|
||||
}, [isMobileLite, loadFull, runFullTickerLoad]);
|
||||
|
||||
// 3) 우선 종목 변경 (lite) — 전체 재시작 없이 보강
|
||||
// 3) 우선 종목 변경 — 디바운스(메뉴·심볼 전환 시 REST 폭주 방지)
|
||||
useEffect(() => {
|
||||
if (!initDoneRef.current || fullLoadedRef.current) return;
|
||||
void loadTickersFor(priorityList);
|
||||
const all = marketListRef.current;
|
||||
if (all.length > 0) attachWs(wsTickerMarkets(all, priorityList));
|
||||
if (!initDoneRef.current) return;
|
||||
const t = setTimeout(() => {
|
||||
if (!mountedRef.current) return;
|
||||
if (!fullLoadedRef.current) void loadTickersFor(priorityList);
|
||||
const all = marketListRef.current;
|
||||
if (all.length > 0) attachWs(wsTickerMarkets(all, priorityList));
|
||||
}, PRIORITY_DEBOUNCE_MS);
|
||||
return () => clearTimeout(t);
|
||||
}, [priorityKey, loadTickersFor, attachWs, priorityList]);
|
||||
|
||||
return { tickers, marketInfos, loading, usdRate };
|
||||
|
||||
@@ -22,3 +22,8 @@ export function useMediaQuery(query: string): boolean {
|
||||
export function useIsMobile(): boolean {
|
||||
return useMediaQuery('(max-width: 768px)');
|
||||
}
|
||||
|
||||
/** 모바일·태블릿 — ticker REST 경량·WS 위주 (≤1024px) */
|
||||
export function useIsCompactDevice(): boolean {
|
||||
return useMediaQuery('(max-width: 1024px)');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user